To examine the association between magnesium intake and risk of type 2 diabetes. We followed 85,060 women and 42,872 men who had no history of diabetes, cardiovascular disease, or cancer at baseline. Magnesium intake was evaluated using a validated food frequency questionnaire every 2-4 years. After 18 years of follow-up in women and 12 years in men, we documented 4,085 and 1,333 incident cases of type 2 diabetes, respectively. After adjusting for age, BMI, physical activity, family history of diabetes, smoking, alcohol consumption, and history of hypertension and hypercholesterolemia at baseline, the relative risk (RR) of type 2 diabetes was 0.66 (95% CI 0.60-0.73; P for trend <0.001) in women and 0.67 (0.56-0.80; P for trend <0.001) in men, comparing the highest with the lowest quintile of total magnesium intake. The RRs remained significant after additional adjustment for dietary variables, including glycemic load, polyunsaturated fat, trans fat, cereal fiber, and processed meat in the multivariate models. The inverse association persisted in subgroup analyses according to BMI, physical activity, and family history of diabetes. Our findings suggest a significant inverse association between magnesium intake and diabetes risk. This study supports the dietary recommendation to increase consumption of major food sources of magnesium, such as whole grains, nuts, and green leafy vegetables.