This research presents the development of a surface treatment for AZ91D magnesium alloy that exhibits both superhydrophobic and anticorrosive properties. Initially, a zinc-based phosphate film was deposited on the magnesium alloy surface. Subsequently, a composite coating with superhydrophobic properties was produced by surface modification using a fluorosilane-ethanol solution. The composite coating’s microstructure, chemical composition, wettability, self-cleaning, and anti-corrosion properties were evaluated using scanning electron microscopy, a contact angle measurement instrument, and an electrochemical workstation. The results demonstrated that the main components of the composite coating were P, O, Zn, F, and C. The static contact angle reached 158°, providing superior self-cleaning and acid and alkali corrosion resistance. Additionally, the charge transfer resistance and coating resistance of the composite coating were significantly higher than those of the magnesium alloy substrate, effectively preventing corrosion and preserving the surface from fouling.