Epidemiological studies on magnesium intake and primary liver cancer (PLC) are scarce, and no prospective studies have examined the associations of magnesium intake with PLC incidence and mortality. We sought to clarify whether higher magnesium intake from diet and supplements was associated with lower risks of PLC incidence and mortality in the US population. Magnesium intake from diet and supplements was evaluated through a food frequency questionnaire in a cohort of 104,025 participants. Cox regression was employed to calculate hazard ratios for PLC incidence and competing risk regression was employed to calculate sub-distribution hazard ratios for PLC mortality. Restricted cubic spline regression was employed to test nonlinearity. We documented 116 PLC cases during 1,193,513.5 person-years of follow-up and 100 PLC deaths during 1,198,021.3 person-years of follow-up. Total (diet + supplements) magnesium intake was found to be inversely associated with risks of PLC incidence (hazard ratio : 0.44; 95% confidence interval: 0.24, 0.80; P = 0.0065) and mortality (sub-distribution hazard ratio : 0.37; 95% confidence interval: 0.19, 0.71; P = 0.0008). Similar results were obtained for dietary magnesium intake. Non-linear inverse dose-response associations with PLC incidence and mortality were observed for both total and dietary magnesium intakes (all P < 0.05). In summary, in the US population, a high magnesium intake is associated with decreased risks of PLC incidence and mortality in a non-linear dose-response manner. These findings support that increasing the consumption of foods rich in magnesium may be beneficial in reducing PLC incidence and mortality. This article is protected by copyright. All rights reserved.This article is protected by copyright. All rights reserved.