To analyze the differences in the composition and abundance of gut microbiota between patients with active pulmonary tuberculosis and healthy controls, and to identify the specific bacteria as biomarkers to distinguish between the two groups. Patients with active pulmonary tuberculosis treated in three municipal designated tuberculosis medical institutions in Sichuan, Jiangsu and Shanghai from September 2017 to September 2019 were selected as the case group (=88), and the healthy people without a history of tuberculosis from the same regions were recruited as the control group (=62). The fecal samples of the two groups were detected by 16S rRNA gene sequencing, and the differences of gut microbiota diversity, community composition and relative abundance at phylum and genus level from the two groups were analyzed. The random forest method was used to construct a predictive model to assess whether the specific bacterial flora could be used as biomarkers to distinguish tuberculosis patients from healthy people. The alpha diversity analysis showed that the species richness and evenness of gut microbiota in tuberculosis patients were significantly lower than those in healthy controls (<0.001). There was a statistically significant difference in the composition of microbiota between the two groups (Bray-Curtis distance, <0.001). In the gut microbiota of tuberculosis patients, opportunistic pathogens were relatively enriched, while some of the beneficial bacteria that can produce short-chain fatty acids were less abundant. The discrimination accuracy of the random forest model composed of , and was 76.67%, with area under the curve (AUC) being 75.29% (95%: 0.661-0.845). There were differences in gut microbiota between patients with active pulmonary tuberculosis and healthy people, and specific bacterial flora showed the potential to be used as biomarkers to distinguish between the two groups.