Magnesium plays a critical role in numerous metabolic functions, including all reactions involving adenosine triphosphate, and is thus essential for the production and use of energy. Magnesium imbalances are common in hospitalized patients, with magnesium deficiency occurring in 20% to 65% of critically ill patients. This article details the homeostatic mechanisms regulating magnesium, the functions of magnesium, and the causes, manifestations, and treatment of both hyper- and hypomagnesemia. Indications and guidelines for the therapeutic uses of magnesium are also reviewed.