The association between serum 25-hydroxyvitamin D [25(OH)D] and type 2 diabetes mellitus (T2DM) remains inconclusive. Moreover, whether inflammatory biomarkers are involved in this association has not been explored. This study aims to investigate serum 25(OH)D in relation to T2DM in a Chinese population and provide clues for the inflammatory mechanism whereby serum 25(OH)D deficiency increases T2DM risk.A cross-sectional study of 47,803 participants aged 18-96 years was performed in a health management center in 2017. Multivariate linear or logistic regression models and mediation analysis were used to examine the relationships between serum 25(OH)D, inflammatory biomarkers (white blood cell counts and mean platelet volume), and T2DM.Of the 47,803 participants included, 5.2% were diabetic and 51.4% were serum 25(OH)D deficient. The study revealed a significant inverse association between serum 25(OH)D and T2DM risk after adjustment for potential confounders (P for trend = 0.002); the multivariate-adjusted odds ratios (ORs) and 95% confidence intervals (CIs) across serum 25(OH)D levels (sufficiency, insufficiency, and deficiency) were 1.00 (reference), 1.17 (1.03-1.33), and 1.25 (1.09-1.43), respectively. This study also showed a significant indirect effect of serum 25(OH)D on T2DM risk through total white blood cell count, neutrophil count, lymphocyte count, and monocyte count (P values < 0.05); the proportions mediated were 9.89%, 7.51%, 2.94%, and 2.82%, respectively.Serum 25(OH)D deficiency was independently associated with an elevated risk of T2DM in a Chinese adult population and low-grade systemic inflammation might be one of its biological mechanisms.