The rising occurrence of infections generated by Escherichia coli and Klebsiella pneumoniae that produce extended-spectrum β-lactamase (ESBL) is reason for concern. Due to the recent emergence of multidrug-resistant microorganisms that develop ESBL. The purpose of this work was to detect the ESBLs in clinical isolates of E. coli and K. pneumoniae. 118 samples of E. coli and 63 isolates of K. pneumoniae were collected from clinical samples. Polymerase chain reaction was used to detect β-lactamase genes (i.e., blaTEM, blaSHV, and blaCTX-M). Phenotypic detection revealed that 48.31% and 85.19% of E. coli and K. pneumoniae produced ESBLs, respectively. Whereas screening of ESBL genes in both bacteria employing a multiplex PCR test revealed that 24.58% of the ESBL-producing E. coli strains contained blaTEM, 50.85% contained blaSHV, and 32.2% contained blaCTX-M. Nevertheless, in K. pneumoniae, 40.74% blaTEM, 35.19% blaSHV, and 64.81% blaCTX-M genes were present. Antimicrobial resistance profiles of E. coli and K. pneumoniae isolates to twenty antibiotics were observed to vary significantly. Additionally, it was determined that the majority of E. coli and K. pneumoniae isolates were multidrug resistant (MDR). Additionally, 80.51% of E. coli isolates were resistant to the AMC antibiotic, while 0.00% were resistant to IPM and MEM. From the other hand, the resistant proportion of K. pneumoniae isolates was heterogeneous, ranging from 69.84% against CAZ to 0.00% against CIP and G antibiotics. The blaSHV gene was the most widespread among different forms of ESBLs in E. coli, but the most common gene in K. pneumoniae isolates was blaCTX-M (64.81%).