Background Dietary magnesium intake inversely correlated to risk of death in general population. However, it is relatively unknown whether the beneficial effect remains significant in individuals with diabetes. Our study purpose is to evaluate the association of dietary magnesium intake with mortality risk in diabetic population. Methods The study population is recruited from 2003-2014 National Health and Nutrition Examination Survey, totaling 2,045 adults with diabetes being included. Participants were divided based on glycohemoglobin (HbA1c < 7% and >= 7%) and daily dietary magnesium intake (<= and > 250mg/day) ascertained by 24-hour dietary recall interviews. Results The average age of the study population was 52.910.1 years, with 49.1% being male. During a median follow-up of 77.0 months (interquartile range: 45.0-107.0 months), a total of 223 participants died (1.5 per 1000 person-months). Our results showed that individuals with lower dietary magnesium intake (<= 250mg/day) had higher risk of all-cause (HR: 1.56, 95% CI: 1.13-2.16) and other-cause (non-cardiovascular and non-cancer) mortality (HR: 1.68, 95% CI: 1.09-2.60), while cardiovascular and cancer-related mortality were similar compared with individuals with magnesium intake > 250mg/day. We also showed that the risk of all-cause (HR: 1.86, 95% CI: 1.33-2.60) and other-cause mortality (HR: 2.03, 95% CI: 1.29-3.19) were higher in individuals with poorly controlled diabetes (HbA1c >= 7.0%) compared with HbA1c <7.0%; however, the association attenuated in the subgroup of higher magnesium intake (>250mg/day). When combining HbA1c and dietary magnesium intake, we showed that individuals with HbA1c >= 7% and dietary magnesium intake <= 250 mg/day had higher all-cause and other-cause (non-cardiovascular and non-cancer) mortality risk compared with those with HbA1c < 7% and/or dietary magnesium intake > 250 mg/day. Conclusion Higher magnesium intake may help reduce mortality risk in individuals with diabetes and attenuate mortality risk of poor diabetic control.