Eighty-five cases community-acquired pneumonia (CAP) in children 5 years or younger, confirmed by chest X-ray, and 185 age-matched control patients with diarrhea or dermatitis from the Outpatient Department at Beijing Children's Hospital were enrolled into this study. Nasopharyngeal swab specimens were obtained from all subjects. Real-time PCR-based fluorescence assays were performed for Chlamydia pneumoniae and Mycoplasma pneumoniae. A nested PCR was also run for C. pneumoniae for comparison of assays. C. pneumoniae was found in 3 (3.5%) of CAP cases and in 4 (2.1%) of controls (P = 0.51). M. pneumoniae was found in 6 (7.1%) of CAP cases and in none of the controls (P = 0.001). The agreement rate of the 2 applied PCR methods used for C. pneumoniae detection was 98.5%. Our study demonstrates that M. pneumoniae may play a significant role in CAP affecting children up to 5 years in China, whereas C. pneumoniae in nasopharyngeal specimens was not associated with CAP in this age group.