Here's the chemical equation:
2 Mg + O₂ → 2 MgO
This reaction produces a bright white light and a lot of heat.
While magnesium oxide is the primary product, a small amount of magnesium nitride (Mg₃N₂) can also form due to the reaction with nitrogen in the air.