A hydrophobic surface was fabricated through the micro-arc oxidation (MAO) and subsequent stearic acid surface modification of AZ31 Mg alloy, achieving a maximum water contact angle of 151.5° after 10h of modification. Through surface analyses and investigation into the corrosion behavior, this hydrophobicity is ascribed to a combination of the MAO coating’s rough micro-pore structure and the formation of a stearic acid monolayer through bidentate bonding. The hydrophobic MAO coating effectively inhibits corrosion of the Mg alloy, especially pitting corrosion, and demonstrates that surface modification could further increase or accelerate the application of MAO treatment to Mg alloys.