Magnesium is a metal that will react with hydrochloric acid. The chemical equation is written below:
Mg + 2HCl --> MgCl2 + H2
The magnesium metal is oxidized to the Mg2+ cation by the loss of two electrons. Both of these electrons then reduce two protons from HCl to produce hydrogen gas (H2). When you do the reaction, you will see the bubbles of H2 form on the magnesium. The MgCl2 is soluble in water so once the magnesium metal is gone you will simply have a clear aqueous solution remaining.
Magnesium is a metal that reacts with hydrochloric acid.
So, the doctors give you milk of magnesia when you have a stomach ache.