A very quick reaction accompanied by a flash that leads to the formation of sodium metal
name: Displacement of metallic sodium from its hydroxide by magnesium
This reaction proceeds due to the fact that magnesium can cleave the oxygen from sodium hydroxide. Under these conditions, sodium can't form a bond with hydrogen. Therefore, sodium and hydrogen are released from the reaction mixture in the form of simple substances. Magnesium becomes magnesium oxide.
Thus, magnesium oxide and sodium metal remain on the bottom of the pot. Hydrogen is released as a gas and is burned.
Sodium is a very light and soft metal. For this reason, it emerges above the oil and may be compressed into a large piece, while magnesium oxide sinks into the aqueous layer and dissolves therein.