The present study was planned to elucidate the therapeutic impact of magnesium as an anti-apoptotic and anti-inflammatory agent, as well as a mediator in various biological and metabolic processes, in protecting liver tissues from the cellular toxicity of multiple chemicals, including heavy metals such as lead (Pb) and cadmium (Cd). The Swiss albino rats were categorized into six treatment groups (n=5). The first group was the control (CN), which received no treatment. The second (Mg), third (Pb), and fourth (Cd) groups were treated with magnesium chloride, lead acetate, and cadmium chloride, respectively, at a dose of 1 mg/kg/day for 15 days. The fifth (Cd + Mg) and sixth groups (Pb + Mg) were given cadmium chloride and lead acetate at 1 mg/kg/day for 15 days, followed by treatment with magnesium chloride (0.5 mg/kg) for 15 days. After the treatment, the animals were sacrificed to retrieve liver and serum samples for biochemical and histological evaluation. The data analysis revealed that both heavy metals, cadmium (Cd) and lead (Pb), induced severe liver injury, as evidenced by higher serum enzymatic activities of alanine aminotransferase (ALT), aspartate aminotransferase (AST), γ-glutamyl transferase (GGT), and lactate dehydrogenase (LDH). At the same time, lipid peroxidation Malondialdehyde (MDA) indices were significantly elevated, along with markedly decreased levels of the non-enzymatic antioxidant glutathione (GSH) in the tissue samples compared to the control. Administration of magnesium at a dose of 0.5 mg/kg significantly reversed most of the serum hepatic biomarker enzymes towards the control levels. Additionally, magnesium significantly reduced lipid peroxidation activity and restored the GSH level in the liver. Furthermore, the histopathological deformations in the liver induced by heavy metals also tended towards restoration, resembling the normal histological architecture of the tissue. Notably, Mg countered Cd-induced toxicity more effectively than Pb. Hence, magnesium acts as a protective element in mitigating the degenerative hepatotoxic effects of lead and cadmium.