Although previous studies in the general population showed that hypomagnesemia is a risk for cardiovascular diseases (CVD), the impact of magnesium on the prognosis of patients on hemodialysis has been poorly investigated. To gain information on this we conducted a nationwide registry-based cohort study of 142,555 hemodialysis patients to determine whether hypomagnesemia is an independent risk for increased mortality in this population. Study outcomes were 1-year all-cause and cause-specific mortality with baseline serum magnesium levels categorized into sextiles. During follow-up, a total of 11,454 deaths occurred, of which 4774 had a CVD cause. In a fully adjusted model, there was a J-shaped association between serum magnesium and the odds ratio of all-cause mortality from the lowest to highest sextile, with significantly higher mortality in sextiles 1-3 and 6. Similar associations were found between magnesium and both CVD and non-CVD mortality. The proportion of patients with a baseline intact parathyroid hormone level under 50 pg/ml was significantly higher in the highest sextile; however, after excluding these patients, the CVD mortality risk in the highest sextile was attenuated. Thus, hypomagnesemia was significantly associated with an increased risk of mortality in hemodialysis patients. Interventional studies are needed to clarify whether magnesium supplementation is beneficial for improving patient prognosis.