The kidneys are crucial for maintaining Mg
2+
homeostasis. Along the proximal tubule and thick ascending limb, Mg
2+
is reabsorbed paracellularly, while along the distal convoluted tubule (DCT), Mg
2+
is reabsorbed transcellularly via transient receptor potential melastatin 6 (TRPM6). TRPM6 and other renal transporter expressions are regulated by sex hormones. To investigate renal Mg
2
handling, we have developed sex-specific computational models of electrolyte transport along rat superficial nephron. Model simulations indicated that along the proximal tubule and thick ascending limb, Mg
2+
and Na
+
transport occur parallelly, but they are dissociated along the DCT. In addition, our models predicted higher paracellular Mg
2+
permeability in females to attain similar cortical thick ascending limb fractional Mg
2+
reabsorption in both sexes. Furthermore, DCT fractional Mg
2+
reabsorption is higher in females than in males, allowing females to better fine-tune Mg
2+
excretion. We validated our models by simulating the administration of three classes of diuretics. The model predicted significantly increased, marginally increased and significantly decreased Mg
2+
excretions for loop, thiazide and K-sparing diuretics, respectively, aligning with experimental findings. The models can be used to conduct
in silico
studies on kidney adaptations to Mg
2+
homeostasis alterations during conditions such as pregnancy, diabetes and chronic kidney disease.