<b><i>Introduction:</i></b> Sclerostin could enhance renal excretion of calcium (Ca) and phosphate (P). The association between sclerostin and magnesium (Mg) has not yet discovered. In patients with type 2 diabetes mellitus (T2DM) or chronic kidney disease (CKD), higher serum sclerostin and altered renal excretion of Ca, P, and Mg were detected. Therefore, we tried to evaluate if there was any association between sclerostin and fractional excretion of Ca, P, and Mg (FeCa, FeP, and FeMg) in T2DM with CKD. <b><i>Methods:</i></b> In this prospective cohort study, 43 T2DM patients without CKD or with CKD stage 1–5 were enrolled. Values of parameters, including serum and urine sclerostin, were collected at baseline and 6 months later. For baseline data, the Mann-Whitney U test, χ<sup>2</sup> test, or Spearman’s correlation were used. For multivariate repeated measurement analysis, generalized estimating equation (GEE) model was utilized. <b><i>Results:</i></b> Patients with lower estimated glomerular filtration rate had higher serum sclerostin, FeP, FeMg, and lower FeCa. By correlation analysis, serum sclerostin was negatively associated with FeCa (<i>p</i> = 0.02) and positively associated with FeP (<i>p</i> = 0.002). The urine sclerostin to creatinine ratio (Uscl/Ucre) was positively correlated with FeP (<i>p</i> = 0.007) and FeMg (<i>p</i> = 0.005). After multivariate analyses by GEE model, serum sclerostin was still inversely associated with FeCa, while Uscl/Ucre was significantly associated with FeMg. On the other hand, FeP lost its associations with serum sclerostin or Uscl/Ucre. <b><i>Conclusion:</i></b> In our study population of T2DM patients with or without CKD, the inverse correlation between serum sclerostin and FeCa could not be explained by the calciuric effect of sclerostin. In addition, a newly discovered positive association between urinary sclerostin and FeMg indicated a possible role of urinary sclerostin in regulating renal Mg handling especially over distal convoluted tubules.