OBJECTIVEMagnesium intake is inversely associated with risk of type 2 diabetes in many observational studies, but few have assessed this association in the context of the carbohydrate quality of the diet. We hypothesized that higher magnesium intake is associated with lower risk of type 2 diabetes, especially in the context of a poor carbohydrate–quality diet characterized by low cereal fiber or high glycemic index (GI) or glycemic load (GL).RESEARCH DESIGN AND METHODSIn the Nurses’ Health Study (NHS; 1984–2012, n = 69,176), NHS2 (1991–2013, n = 91,471), and the Health Professionals’ Follow-Up Study (1986–2012, n = 42,096), dietary intake was assessed from food frequency questionnaires every 4 years. Type 2 diabetes was ascertained by biennial and supplementary questionnaires. We calculated multivariate hazard ratios (HRs) of magnesium intake and incident diabetes, adjusted for age, BMI, family history of diabetes, physical activity, smoking, hypertension, hypercholesterolemia, GL, energy intake, alcohol, cereal fiber, polyunsaturated fats, trans fatty acids, and processed meat, and we considered the joint associations of magnesium and carbohydrate quality on diabetes risk.RESULTSWe documented 17,130 incident cases of type 2 diabetes over 28 years of follow-up. In pooled analyses across the three cohorts, those with the highest magnesium intake had 15% lower risk of type 2 diabetes compared with those with the lowest intake (pooled multivariate HR in quintile 5 vs. 1: 0.85 [95% CI 0.80–0.91], P < 0.0001). Higher magnesium intake was more strongly associated with lower risk of type 2 diabetes among participants with high GI or low cereal fiber than among those with low GI or high cereal fiber (both P interaction <0.001).CONCLUSIONSHigher magnesium intake is associated with lower risk of type 2 diabetes, especially in the context of lower carbohydrate–quality diets.