The balanced chemical equation for this reaction is:
$$Mg(s) + 2HCl(aq) → MgCl_2(aq) + H_2(g)$$
In this reaction, magnesium atoms lose two electrons to become magnesium ions, while hydrogen ions gain electrons to become hydrogen gas. The magnesium ions and chloride ions then combine to form magnesium chloride, a salt.