Early life is a “critical window” for gut microbiota development, antibiotic use during this period exerts a profound effect on gut microbial dysbiosis and asthma. In clinical practice, antibiotics are usually used in patients with bacterial infections, we previously showed that neonatal S. pneumoniae pneumonia promoted adult-onset asthma in mice model, while it remains unclear whether neonatal S. pneumoniae infection have long-term effects on gut microbiota. Neonatal BALB/c mice were inoculated with 5*106 CFU D39 to establish non-lethal S. pneumoniae pneumonia model. At 2, 3, 8 weeks of age, feces in the cecum were prepared for 16S rRNA sequencing, lungs were collected for histopathologic and lung function analysis. S. pneumoniae-infected neonatal mice exhibited histopathologic lesions in their lungs and increased airway hyperresponsiveness, obvious alterations in alpha and beta diversities in the entire gut microbiota, and changes of the community structure during the breastfeeding period, infancy, and adulthood. Furthermore, gut microbial composition was modified after neonatal S. pneumoniae infection, with a decreased relative abundance of Lactobacillus in the breastfeeding period and infancy; in adulthood, the relative abundance of Allobaculum diminished while that of Proteobacteria was augmented. Neonatal S. pneumoniae infection induced a long-term alteration in microbial community composition.