Magnesium chloride is a chemical compound made of magnesium and chlorine. It has the chemical formula MgCl2. It is the main ingredient used to make magnesium metal.
It is hygroscopic, meaning it attracts water to form hydrates easily.
Hydrated magnesium chloride is mostly made from brine. The anhydrous (water-free) salt cannot be made by heating the hydrate because it will decompose into hydrogen chloride and magnesium hydroxychlorides. Instead, the water-free salt is made by heating ammonia complexes.
Electrolysis of molten magnesium chloride is the main way people make elemental magnesium metal. This also makes chlorine gas.[source?] Magnesium chloride can also be reduced by strong reducing agents like potassium.