Magnesium is an essential mineral for bone metabolism. However, little is known about the relationship between magnesium and the risk of fractures. In this cohort study, we elucidated the association between serum magnesium level and the risk of incident hip fracture among patients undergoing hemodialysis. We identified 113,683 patients undergoing hemodialysis with no history of hip fracture from a nation-wide database of patients undergoing dialysis in Japan. During a 2-year follow-up, a total of 2305 (2%) new hip fractures occurred. The crude incidence rate was significantly higher among patients in the lower quartiles of serum magnesium levels (2.63%, 2.08%, 1.76%, and 1.49% in Q1–Q4, respectively; P<0.001 for trend). The range of serum magnesium levels (in milligrams per deciliter) in each quartile was as follows: Q1, <2.3; Q2, 2.4–2.6; Q3, 2.7–2.8, and Q4, >2.9. After adjustment for demographic and clinical factors, patients in Q1 had a 1.23-fold higher risk for hip fracture than those in Q4 (95% confidence interval, 1.06 to 1.44; P<0.01). Similarly, an inverse probability weighting analysis showed an increased risk of hip fracture among patients in the lower magnesium quartiles. We did not observe significant effect modifications in subgroup analyses. The population-attributable fraction of serum magnesium level for incident hip fractures was 13.7% (95% confidence interval, 3.7% to 22.7%), which was much higher than that of serum calcium, serum phosphate, and parathyroid hormone levels. Thus, mild hypermagnesemia is associated with a lower risk of hip fracture among patients undergoing hemodialysis.