There are a variety of interesting genetic diseases that can cause hereditary Magnesium wasting.
Renal magnesium handling is a little different than other ions in that the primary site of reabsorption is not the proximal convoluted tubule. Rather, the majority of Mg reabsorption occurs in the thick ascending limb (TAL). The key protein is termed paracellin, or claudin-16, which forms channels in the paracellular barrier which allows passage of the divalent cations Ca2+ and Mg2+. Thus, mutations in paracellin can result in both urinary Ca and urinary Mg wasting.
Ca2+ & Mg2+ reabsorption via the paracellular route is also linked to Na reabsorption. Recall that the Na/K/2Cl loop-sensitive Na channel is responsible for Na reabsorption in the TAL; although this is an electroneutral transporter, the backleak of K via ROMK channels creates a positive lumenal potential that drives Ca2+ and Mg2+ paracellular transport. This is why addition of a loop diuretic can lead to Ca2+ and Mg2+ wasting in the urine.
Some Mg reabsorption also takes place in the distal convoluted tubule (DCT) via a transcellular transport mechanism in which Mg is taken up via an apical Mg channel called TRPM6. It has recently been determined that epidermal growth factor receptor (EGFR) signaling is required for proper trafficking of TRPM6. Mutations in TRPM6 (causing the genetic disorder "hypomagnesemia with secondary hypocalcemia") as well as mutations in EGF can both therefore lead to urinary magnesium wasting.
Gitelman's Syndrome (caused by mutations in the thiazide-sensitive Na channel in the distal convoluted tubule) also results in chronic renal Mg wasting. Finally, an autosomal dominant-inherited dominant negative mutation in the Na-K ATPase also mysteriously results in isolated Mg wasting.
By the way, the image above (entitled "Magnesium Dice") is from an electron micrograph of some magnesium oxide crystals.