AZ31 alloy has excellent properties like ultra-low density, good energy absorption, and high damping performance but has poor corrosion resistance. The influence of media pH on the corrosion of AZ31 alloy in chloride and sulphate media was investigated using such electrochemical techniques as potentiodynamic polarization and electrochemical impedance spectroscopy (EIS). The tests were carried out by varying pH in different concentrations (0.05–0.25M) of the media. The surface morphologies and surface compositions of the corroded alloy surfaces were analyzed using scanning electron microscopy and energy-dispersive X-ray spectroscopy, respectively. Conclusively, the recorded results reflect a trend of a higher corrosion rate at higher concentrations of the media; and an increase in the corrosion rate on decreasing the pH of the media. In the studied pH range, the alloy showed a higher corrosion resistance at pH 11 and a lower corrosion resistance at pH 3.