Background: Diabetes mellitus (DM) is a major risk factor for tuberculosis (TB). Evidence has linked the DM-related dysbiosis of gut microbiota to modifiable host immunity to Mycobacterium tuberculosis infection. However, the crosslinks between gut microbiota composition and immunological effects on the development of latent TB infection (LTBI) in DM patients remain uncertain. Methods: We prospectively obtained stool, blood samples, and medical records from 130 patients with poorly-controlled DM (pDM), defined as ever having an HbA1c > 9.0% within previous 1 year. Among them, 43 had LTBI, as determined by QuantiFERON-TB Gold in-Tube assay. The differences in the taxonomic diversity of gut microbiota between LTBI and non-LTBI groups were investigated using 16S ribosomal RNA sequencing, and a predictive algorithm was established using a random forest model. Serum cytokine levels were measured to determine their correlations with gut microbiota. Results: Compared with non-LTBI group, the microbiota in LTBI group displayed a similar alpha-diversity but different beta-diversity, featuring decrease of Prevotella_9, Streptococcus, and Actinomyces and increase of Bacteroides, Alistipes, and Blautia at the genus level. The accuracy was 0.872 for the LTBI prediction model using the aforementioned 6 microbiome-based biomarkers. Compared with the non-LTBI group, the LTBI group had a significantly lower serum levels of IL-17F (p = 0.025) and TNF-α (p = 0.038), which were correlated with the abundance of the aforementioned 6 taxa. Conclusions: The study results suggest that gut microbiome composition maybe associated with host immunity relevant to TB status, and gut microbial signature might be helpful for the diagnosis of LTBI.