PurposeTo improve the corrosion resistance of magnesium alloys, the construction of protective coatings is necessary to extend the service life of Mg-based materials.Design/methodology/approachSiO2 nanoparticles modified by dodecyltrimethoxysilane (DTMS) were added to the PP and a superhydrophobic Mg(OH)2/PP-60mSiO2 composite coating was fabricated on the surface of AZ31 magnesium alloy via the hydrothermal method and subsequently the immersion treatment.FindingsHydrophilic SiO2 nanoparticles become hydrophobic after modified by DTMS, showing a higher dispersibility in xylene. By incorporating modified SiO2 nanoparticles into the composite PP coating, the hydrophobicity of the layer was enhanced, resulting in a contact angle of 166.3° and a sliding angle of 3.4°. It also improved the water repellency and durability of the coating. Furthermore, the intermediate layer of Mg(OH)2 significantly strengthened the bond between the PP layer and the substrate. The Mg(OH)2/PP-60mSiO2 composite coating significantly enhances the corrosion resistance of the magnesium alloy by effectively blocking the infiltration of the corrosion anions during corrosion. The corrosion current density of the Mg(OH)2/PP-60mSiO2 composite coating is approximately 8.23 × 10–9 A·cm-2, which can achieve a magnitude three times lower than its substrate, making it a promising surface modification for the Mg alloy.Originality/valueThe composite coating effectively and durably enhances the corrosion resistance of magnesium alloys.