The presence of extended-spectrum beta-lactamase (ESBL)-producing Klebsiella pneumoniae in fresh fruits and vegetables is a growing public health concern. The primary objective of this study was to investigate the relationship between biofilm formation and extended-spectrum beta-lactamase (ESBL) production in K. pneumoniae strains obtained from fresh fruits and vegetables. Out of 120 samples analysed, 94 samples (78%) were found to be positive for K. pneumoniae. Among the K. pneumoniae strains isolated, 74.5% were from vegetables, whereas the remaining (25.5%) were from fresh fruits. K. pneumoniae isolates were resistant to at least three different classes of antibiotics, with ceftazidime (90%) and cefotaxime (70%) showing the highest resistance rates. While the high occurrence of ESBL-producing and biofilm-forming K. pneumoniae strains were detected in vegetables (73.5% and 73.7%, respectively), considerable amounts of the same were also found in fresh fruits (26.5% and 26.3%, respectively). The results further showed a statistically significant (P < 0.001) association between biofilm formation and ESBL production in K. pneumoniae strains isolated from fresh fruits and vegetables. Furthermore, the majority (81%) of the ESBL-producing strains harbored the blaCTX-M gene, while a smaller proportion of strains carried the blaTEM gene (30%), blaSHV gene (11%) or blaOXA (8%). This study highlights the potential public health threat posed by K. pneumoniae in fresh fruits and vegetables and emphasizes the need for strict surveillance and control measures.