The co-occurrence of tuberculosis (TB) and diabetes mellitus (DM) presents a significant obstacle to TB eradication. Pulmonary cavitation can occur in severe cases of TB, particularly in patients with DM. From 1 May 2014 through 30 June 2019, we conducted a cross-sectional study of 1,658 smear- or culture-confirmed pulmonary TB (PTB) patients at the Second Department of Pulmonary Medicine and Tuberculosis, Shenzhen, China. A total of 861 participants who satisfied the criteria (chest CT scan for cavitation, interferon-gamma release assay (IGRA), diagnosis of diabetes mellitus), with the median age of 36.7 years, 63.6% of male, 79.7% IGRA positive, 13.8% with diabetes, and 40.8% with pulmonary cavitation, were included in the study. The association between diabetes and pulmonary cavitation was confirmed in these TB patients (adjusted OR, 2.54; 95% CI, 1.66–3.94; p < 0.001). No associations were observed between diabetes and IGRA, as well as between lung cavitary and IGRA. Based on the criteria of IGRA+/–, pulmonary cavitation+/–, and DM+/–, the further analysis with univariate and multivariate logistic regression were conducted in six subgroups. The significant association between diabetes and pulmonary cavitation was further confirmed in the IGRA+ subgroup (adjusted OR, 3.07; 95% CI, 1.86–5.16; p < 0.001) but not observed in IGRA- individuals. This observation suggests that different immunological mechanisms of pulmonary cavitary/DM may be employed in IGRA+ TB patients from IGRA- TB patients.