Abstract In this research, solid diffusion process was used to form a diffusion alloying layer on the surface of ZM5 magnesium alloy to improve corrosion and wear resistance. It is shown that the solid diffusion layer was mainly composed of Mg–Al–Zn intermetallic compounds and Mg–Al–Zn solid solution transition zone that had more Zn and Al elements than untreated ZM5 magnesium substrate. The continued immersion test in 3% NaCl solution displayed that the diffusion-treated specimen had better corrosion resistance compared to the untreated ZM5 specimen. The polarization test indicated that the Mg–Al–Zn intermetallic compounds of the diffusion alloying layer were an effective corrosion barrier to decrease the corrosion rate for ZM5 magnesium alloy when exposed to 3% NaCl solutions. In addition, the microhardness values of the Mg–Al–Zn intermetallic compounds were much higher than those of the substrate and this would greatly contribute to the enhancement of wear resistance.