BackgroundMagnesium ion metabolism disorder is pervasive in the chronic kidney disease population, which is affected by many factors. Magnesium ion plays an important role in maintaining vascular functional integrity.. The Magnesium Depletion Score (MDS), serving as a novel metric for the assessment of magnesium deficiency, has not been thoroughly investigated for its association with stroke in patients with chronic kidney disease (CKD). Therefore, this study aims to explore the relationship between the MDS index and stroke in CKD patients. MethodsWe conducted a cross-sectional population-based study using data from the National Health and Nutrition Examination Survey 2009–2016 to explore the impact of MDS on the stroke outcome of CKD patients. The primary outcome was the risk of stroke in CKD patients. Sample-weighted multivariate logistic regression was used in our analysis. ResultsIn this study of 3536 CKD patients from the database, we found an 8.6 % prevalence of stroke with higher stroke risk in older individuals and males. Lower dietary magnesium intake and higher MDS scores were significantly associated with stroke risk. Multivariate logistic regression analysis revealed a dose-dependent relationship between MDS scores and stroke likelihood, independent of demographic and clinical factors. Subgroup analysis confirmed these findings, particularly in those with hypertension, diabetes, and obesity, without significant interactions (all p > 0.05). ConclusionMagnesium depletion is independently associated with a heightened stroke risk in chronic kidney disease patients.