The reaction between magnesium and hydrochloric acid is exothermic, meaning it releases heat. The heat is produced from the chemical energy stored in the reactants, which converts to thermal energy during the reaction, causing the temperature of the mixture to rise. This thermal energy is then lost to the surroundings, returning the temperature to normal.