To investigate the relationship between diabetes mellitus (DM) and the risk of central nervous system tuberculosis (CNS-TB), to analyze the age-dependent characteristics of this association, and to assess the combined effects of DM and neutrophil-to-lymphocyte ratio (NLR). We retrospectively analyzed clinical data of 862 extrapulmonary tuberculosis patients admitted to Fuzhou Pulmonary Hospital from April 2018 to April 2024, including 685 non-CNS extrapulmonary tuberculosis (non-CNS EPTB) patients and 177 CNS-TB patients. Baseline demographic and laboratory characteristics were compared between groups. Age-stratified analysis (≤40 years, 41–60 years, >60 years) was performed to evaluate the age-dependent nature of the association between diabetes and CNS-TB risk. Multivariate logistic regression analysis was used to identify independent risk factors for CNS-TB, and to assess the combined effects and interaction between diabetes and NLR. The prevalence of DM was significantly higher in the CNS-TB group than in the non-CNS EPTB group (24.29% vs 12.26%, P<0.001), with significantly elevated NLR (P<0.001). Age-stratified analysis revealed that the association between diabetes and CNS-TB risk exhibited significant age dependence, with no significant correlation in the ≤40 years group (OR=1.52, 95% CI: 0.47–4.94, P=0.506), but significant associations in the 41–60 years group (OR=2.80, 95% CI: 1.40–5.63, P=0.003) and >60 years group (OR=2.22, 95% CI: 1.20–4.13, P=0.010). Multivariate analysis confirmed DM (adjusted OR=2.116, 95% CI: 1.382–3.241, P<0.001) and NLR (adjusted OR=1.051, 95% CI: 1.022–1.080, P4.194) had the highest risk of CNS-TB (adjusted OR=4.833, 95% CI: 2.737–8.535, P<0.001), with a proportion of 38.4%. However, formal interaction analysis indicated no evidence of a statistically significant additive interaction (RERI=0.198, 95% CI: −2.772–3.169, P=0.896). DM is an independent risk factor for CNS-TB, significantly increasing risk in individuals aged >40 years. DM and NLR independently contribute to CNS-TB risk, supporting clinical risk assessment and prevention strategies incorporating metabolic and inflammatory biomarkers.