The aim of this study was to explore the association between serum Mg and cardiovascular mortality in the peritoneal dialysis (PD) population. This prospective cohort study included prevalent PD patients from a single centre. The primary outcome of this study was cardiovascular mortality. Serum Mg was assessed at baseline. A total of 402 patients (57 % male; mean age 49·3±14·9 years) were included. After a median of 49·9 months (interquartile range: 25·9-68·3) of follow-up, sixty-two patients (25·4 %) died of CVD. After adjustment for conventional confounders in multivariate Cox regression models, being in the lower quartile for serum Mg level was independently associated with a higher risk of cardiovascular mortality, with hazards ratios of 2·28 (95 % CI 1·04, 5·01), 1·41 (95 % CI 0·63, 3·16) and 1·62 (95 % CI 0·75, 3·51) for the lowest, second and third quartiles, respectively. A similar trend was observed when all-cause mortality was used as the study endpoint. Further analysis showed that the relationships between lower serum Mg and higher risk of cardiovascular and all-cause mortality were present only in the female subgroup, and not among male patients. The test for interaction indicated that the associations between lower serum Mg and cardiovascular and all-cause mortality differed by sex (P=0·008 and P=0·011, respectively). In conclusion, lower serum Mg was associated with a higher risk of cardiovascular and all-cause mortality in the PD population, especially among female patients.