When magnesium reacts with hydrochloric acid, hydrogen gas is produced, along with a salt called magnesium chloride.