The association between dietary quality and type 2 diabetes mellitus (T2DM) based on the Chinese Dietary Balance Index (DBI-16) is seldom reported. We hypothesized that poor dietary quality might increase the risk of T2DM in the middle-aged and older populations. A total of 1816 individuals (≥50 years) were included in the study. Demographic characteristics and dietary intake data were collected. Logistic regression and restricted cubic spline (RCS) analyses were conducted to explore the association between DBI-16 indexes and the risk of T2DM. The insufficient intake of vegetables and dairy might decrease the risk of T2DM (ORVegetable = 0.77, 95% CI = 0.60-0.97; ORDairy = 0.58, 95% CI = 0.35-0.96), but the individuals with insufficient intake of fruit were more likely to have a higher risk of T2DM (ORfruit = 2.26, 95% CI = 1.69-3.06). Compared with the subjects with the lowest quartile of Low Bound Score (LBS) or Diet Quality Distance (DQD), the individuals with Q2 and Q3 level of LBS (ORQ2 = 1.40, 95% CI = 1.03-1.90, P = .033; ORQ3 = 1.52, 95% CI = 1.11-2.08, P < .01) or DQD (ORQ2 = 1.45, 95% CI = 1.06-1.99, P = .021; ORQ3 = 1.64, 95% CI = 1.20-2.24, P < .01) showed increased risk of T2DM with a nonlinear association observed by RCS analysis. We concluded that imbalanced dietary intake, especially insufficient daily fruit intake, might predict an increased risk of T2DM in the middle-aged and elderly Chinese.