Magnesium depletion causes hypocalcemia through two main mechanisms: 1) Resistance to parathyroid hormone when magnesium levels fall below 0.8 meq/L, and 2) Decreased secretion of parathyroid hormone in patients with more severe hypomagnesemia. Severe hypermagnesemia above 6 mg/dL can also cause hypocalcemia by suppressing parathyroid hormone secretion.