Background: Organisms producing CTX-M b-lactamases are emerging as a source of resistance to oxyiminocephalosporins such as ceftriaxone and ceftazidime. However, the laboratory detection of these strains is not well defined. The aim of this study was to determine the prevalence of CTX-M and associated risk factors for community-acquired Klebsiella pneumoniae in Sanandaj, Iran.Methods: In this study, 100 Klebsiella pneumonia strains community- acquired were used. The pattern of antimicrobial resistance was determined by double disk diffusion method. The ESBL production was determined by combination disk method using disks containing Cefepime, Cefpodoxime, ceftazidime and cefotaxim alone and in combination with Clavulanic acid. CTX-M type of ESBL producing genes were detected by pcr. A possible clonal relationship among the strains was determined by repetitive extragenic palindromic sequence pcr.Results: Confirmatory phenotypic test showed that 88% of the strains were ESBL positive. pcr used for the detection of CTX-M gene, showed that 37 (42.04%) out of 88 isolates contained such gene. Base on rep-pcr, 31 genotypes among 37 CTX-M-positive samples were detected. According to statistical analysis, the followings were identified as independent risk factors: age (P value: 0.006, 95%CI: 2.613- 15.084), pregnant (P value: 0.036, OR: 5.903, 95% CI: 1.125- 30.975), previous hospitalization in the past 3 months (P value<0.001, OR: 11.96, 95% CI: 4.541-31.491), time of hospitalization (P value<0.001), antibiotic treatment in the past 3 months (P value: 0.016, OR: 2.806, 95% CI: 1.208-6.518), having relatives in hospital staff (P value: 0.001, OR: 12.904, 95% CI: 2.671-62.336), Diabetes Distance under 2 km from the hospital.Conclusion: Noticing the increasing rate of the ESBLs producing strains, using the appropriate treatment protocol based on the pcr pattern of the strains is highly recommended. Hospitals and hospital staff should have more hygiene, proper disposal of hospital waste and the use of antibiotics only if prescribed by a doctor can help prevent the spread of ESBL.