Background: Machine learning (ML) applied to lung and gut microbiota offers substantial yet underexplored potential for improving tuberculosis (TB) diagnosis and prognosis. Progress has been limited by insufficiently large and standardised datasets. Here, we applied ML models to globally curated microbiota datasets to distinguish study-defined TB cases from study-defined controls. Methods: Datasets were from our recently published systematic review of 11 studies (2017–2026), in addition to 11 reporting microbiota changes associated with TB. The harmonised lung and gut datasets include n= 2859 Samples. Six ML model types were optimised across 36 parameters for TB- and treatment-status classification. Model training, cross, internal (using 72%, 18%, and 10% of the data) and external validation using a dataset from China. Findings: The dataset included 1,933 lung and 920 gut microbiota samples, of which 1,959 (68.7%) were microbiologically confirmed TB cases; 93% of samples originated from Africa and Asia. In the global lung dataset, Lasso II , Ridge II and Random Forest models achieved an area under the receiver operating characteristic curve (AUROC) of 0.93, 0.90 and 0.90 during cross‑validation and internal validation correctly classified 140 of 148 TB cases. The external validation (n=76 from China) correctly classifies 18 of 31 cases. Although Africa‑ and Asia‑specific models were comparable to performance of global models during cross‑validation, their performance did not generalise in external validation. Random Forest models performed best in classifying treatment versus non-treatment showing potential in staging treatment progression. Genera such as Rothia, Prevotella, Haemophilus and Streptococcus consistently ranked among the strongest predictors of pulmonary TB, suggesting potential biomarker value. Interpretation: This study is proof of principle that ML models can leverage lung and gut microbiota to develop complementary tools for potential clinical relevance, particularly for extrapulmonary or hard‑to‑diagnose cases. This work provides a foundation for future clinical metagenomics in TB diagnostics and prognostics. To support reproducibility and future innovation, we release MLTBdx, an open‑source pipeline and dataset.