Magnesium alloys have great potential for industrial and aerospace applications due to their low density and high strength. Aiming at its defects of poor corrosion resistance and susceptibility to galvanic coupling corrosion in metal coatings, a composite coating was prepared on the surface of AZ91D magnesium alloy by the hydrothermal method. Scanning electron microscope, x-ray diffraction, and x-ray photoelectron spectroscopy were used to characterize the surface micromorphology, phase composition, and elemental valence and evaluate the adhesion of the coating to the substrate by the ASTM D3359-09 test standard. Electrochemical experiments were done in a 3.5% NaCl solution. The results show that there are nanoscale dense granular structures on the surface of the samples, and the main components of the coatings are Mg(OH)2, Al2O3, and MgSiO3. ASTM grade 4B is between coating and substrate. The corrosion rate of the best sample was reduced by a factor of 238.96 compared to the substrate, and the corrosion current density was reduced by two orders of magnitude. The corrosion rate and corrosion current of the samples after repeated friction did not change much compared with those before friction, which proved that the composite coating had better corrosion resistance and friction stability.