Background Extended spectrum betalactamase (ESBL)-producing organisms are a major cause of hospital-acquired infections. ESBL-producing Escherichia coli (E. coli) have been recovered from the hospital environment. These drug-resistant organisms have also been found to be present in humans as commensals. The present investigation intended to isolate ESBL-producing E. coli from the gut of already infected patients; to date, only a few studies have shown evidence of the gut microflora as a major source of infection. Aims This study aimed to detect the presence of ESBL genes in E.coli that are isolated from the gut of patients who have already been infected with the same organism. Methods A total of 70 nonrepetitive faecal samples were collected from in-patients of our hospital. These in-patients were clinically diagnosed and were culture-positive for ESBL-producing E. coli either from blood, urine, or pus. Standard microbiological methods were used to detect ESBL from clinical and gut isolates. Genes coding for major betalactamase enzymes such as blaCTX-M, blaTEM, and blaSHV were investigated by polymerase chain reaction (PCR). Results ESBL-producing E. coli was isolated from 15 (21 per cent) faecal samples of the 70 samples that were cultured. PCR revealed that out of these 15 isolates, the blaCTX-M gene was found in 13 (86.6 per cent) isolates, the blaTEM was present in 11 (73.3 per cent) isolates, and blaSHV only in eight (53.3 per cent) isolates. All 15 clinical and gut isolates had similar phenotypic characters and eight of the 15 patients had similar pattern of genes (blaTEM, blaCTX-M, and blaSHV) in their clinical and gut isolates. Conclusion Strains with multiple betalactamase genes that colonise the gut of hospitalised patients are a potential threat and it may be a potential source of infection