OBJECTIVE: We investigated whether serum magnesium (Mg2+) was prospectively associated with macro- or microvascular complications and mediated by glycemic control (hemoglobin A1c [HbA1c]), in type 2 diabetes (T2D). RESEARCH DESIGN AND METHODS: We analyzed in 4,348 participants the association of serum Mg2+ with macrovascular disease and mortality (acute myocardial infarction [AMI], coronary heart disease [CHD], heart failure [HF], cerebrovascular accident [CVA], and peripheral arterial disease [PAD]), atrial fibrillation (AF), and microvascular complications (chronic kidney disease [CKD], diabetic retinopathy, and diabetic foot) using Cox regression, adjusted for confounders. Mediation analysis was performed to assess whether HbA1c mediated these associations. RESULTS: The average baseline serum Mg2+ concentration was 0.80 ± 0.08 mmol/L. During 6.1 years of follow-up, serum Mg2+ was inversely associated with major macrovascular, 0.87 (95% CI 0.76; 1.00); HF, 0.76 (95% CI 0.62; 0.93); and AF, 0.59 (95% CI 0.49; 0.72). Serum Mg2+ was not associated with AMI, CHD, CVA, and PAD. During 5.1 years of follow-up, serum Mg2+ was inversely associated with overall microvascular events, 0.85 (95% CI 0.78; 0.91); 0.89 (95% CI 0.82; 0.96) for CKD, 0.77 (95% CI 0.61; 0.98) for diabetic retinopathy, and 0.85 (95% CI 0.78; 0.92) for diabetic foot. HbA1c mediated the associations of serum Mg2+ with HF, overall microvascular events, diabetic retinopathy, and diabetic foot. CONCLUSIONS: Serum Mg2+ concentration is inversely associated with the risk to develop HF and AF and with the occurrence of CKD, diabetic retinopathy, and foot complications in T2D. Glycemic control partially mediated the association of serum Mg2+ with HF and microvascular complications.