Magnesium (Mg) is the main intracellular divalent cation, and under basal conditions the small intestine absorbs 30-50% of its intake. Normal serum Mg ranges between 1.7-2.3 mg/dl (0.75-0.95 mmol/l), at any age. Even though eighty percent of serum Mg is filtered at the glomerulus, only 3% of it is finally excreted in the urine. Altered magnesium balance can be found in diabetes mellitus, chronic renal failure, nephrolithiasis, osteoporosis, aplastic osteopathy, and heart and vascular disease. Three physiopathologic mechanisms can induce Mg deficiency: reduced intestinal absorption, increased urinary losses, or intracellular shift of this cation. Intravenous or oral Mg repletion is the main treatment, and potassium-sparing diuretics may also induce renal Mg saving. Because the kidney has a very large capacity for Mg excretion, hypermagnesemia usually occurs in the setting of renal insufficiency and excessive Mg intake. Body excretion of Mg can be enhanced by use of saline diuresis, furosemide, or dialysis depending on the clinical situation.