Background: Tuberculosis is a major contributor to the global burden of disease, causing more than a million deaths annually. Given an emphasis on equity in access to diagnosis and treatment of tuberculosis in global health targets, evaluations of differences in tuberculosis burden by sex are crucial. We aimed to assess the levels and trends of the global burden of tuberculosis, with an emphasis on investigating differences in sex by HIV status for 204 countries and territories from 1990 to 2019. Methods: We used a Bayesian hierarchical Cause of Death Ensemble model (CODEm) platform to analyse 21 505 site-years of vital registration data, 705 site-years of verbal autopsy data, 825 site-years of sample-based vital registration data, and 680 site-years of mortality surveillance data to estimate mortality due to tuberculosis among HIV-negative individuals. We used a population attributable fraction approach to estimate mortality related to HIV and tuberculosis coinfection. A compartmental meta-regression tool (DisMod-MR 2.1) was then used to synthesise all available data sources, including prevalence surveys, annual case notifications, population-based tuberculin surveys, and tuberculosis cause-specific mortality, to produce estimates of incidence, prevalence, and mortality that were internally consistent. We further estimated the fraction of tuberculosis mortality that is attributable to independent effects of risk factors, including smoking, alcohol use, and diabetes, for HIV-negative individuals. For individuals with HIV and tuberculosis coinfection, we assessed mortality attributable to HIV risk factors including unsafe sex, intimate partner violence (only estimated among females), and injection drug use. We present 95% uncertainty intervals for all estimates. Findings: Globally, in 2019, among HIV-negative individuals, there were 1·18 million (95% uncertainty interval 1·08–1·29) deaths due to tuberculosis and 8·50 million (7·45–9·73) incident cases of tuberculosis. Among HIV-positive individuals, there were 217 000 (153 000–279 000) deaths due to tuberculosis and 1·15 million (1·01–1·32) incident cases in 2019. More deaths and incident cases occurred in males than in females among HIV-negative individuals globally in 2019, with 342 000 (234 000–425 000) more deaths and 1·01 million (0·82–1·23) more incident cases in males than in females. Among HIV-positive individuals, 6250 (1820–11 400) more deaths and 81 100 (63 300–100 000) more incident cases occurred among females than among males in 2019. Age-standardised mortality rates among HIV-negative males were more than two times greater in 105 countries and age-standardised incidence rates were more than 1·5 times greater in 74 countries than among HIV-negative females in 2019. The fraction of global tuberculosis deaths among HIV-negative individuals attributable to alcohol use, smoking, and diabetes was 4·27 (3·69–5·02), 6·17 (5·48–7·02), and 1·17 (1·07–1·28) times higher, respectively, among males than among females in 2019. Among individuals with HIV and tuberculosis coinfection, the fraction of mortality attributable to injection drug use was 2·23 (2·03–2·44) times greater among males than females, whereas the fraction due to unsafe sex was 1·06 (1·05–1·08) times greater among females than males. Interpretation: As countries refine national tuberculosis programmes and strategies to end the tuberculosis epidemic, the excess burden experienced by males is important. Interventions are needed to actively communicate, especially to men, the importance of early diagnosis and treatment. These interventions should occur in parallel with efforts to minimise excess HIV burden among women in the highest HIV burden countries that are contributing to excess HIV and tuberculosis coinfection burden for females. Placing a focus on tuberculosis burden among HIV-negative males and HIV and tuberculosis coinfection among females might help to diminish the overall burden of tuberculosis. This strategy will be crucial in reaching both equity and burden targets outlined by global health milestones. Funding: Bill & Melinda Gates Foundation.