How Does Magnesium React With Oxygen?

Magnesium has a very energetic combustion reaction with oxygen, where two atoms of magnesium bond with one molecule of oxygen gas to form two molecules of magnesium oxide. This reaction is extremely exothermic, releasing a great deal of heat and light, which is why magnesium fuses are used to initiate reactions such as the thermite reaction, and magnesium is used in flares for high visibility. The reaction of magnesium to oxygen is so energetically favorable that burning magnesium can steal the oxygen from both water and carbon dioxide, making these common methods of dousing flames ineffective to stop magnesium combustion.
Magnesium is an alkaline earth metal which is highly reactive because of its strong tendency to lose two electrons for more stable electron orbitals. This property is one reason why it reacts so strongly with oxygen, which tends to take on two extra electrons for a more stable configuration. Magnesium has an atomic number one greater than sodium, an even more reactive metal. Magnesium is also a crucial nutrient for many animals, including humans, where it plays several roles alongside calcium, another alkaline earth metal directly below it on the periodic table.
Magnesium fires are dangerous, requiring a dry powder fire extinguisher and eye protection for its very bright combustion to handle safely.