Micro-arc oxidation (MAO) treatment is a simple and effective technique to improve the corrosion resistance for magnesium alloys. However, the presence of micro-pores and cracks on the coatings provides paths for corrosive ions to penetrate into and react with the substrate, limiting the long-term corrosion resistance. In this paper, we designed a composite coating with which GelMA hydrogel coatings with varying thicknesses were prepared on the surface of MAO-coated magnesium alloys via a dip-coating method, aiming to improve the biocorrosion resistance and biocompatibility. The surface morphology, the chemical composition of GelMA hydrogels, and the crystallographic structure of magnesium alloys were characterized by scanning electron microscope (SEM), Fourier-transform infrared spectroscopy (FTIR), and X-ray diffraction (XRD), respectively. The corrosion resistance and biocompatibility of all samples were evaluated through electrochemical and biological experiments. The results demonstrated that the addition of GelMA hydrogel could effectively seal the pores and improve the corrosion resistance and biocompatibility of MAO-coated magnesium alloys, especially for the sample with one layer of GelMA hydrogel, showing high cell proliferation rate, and its current density (Icorr) was two orders of magnitude lower than that of the MAO coating. Besides, the balance mechanism between corrosion and protection was proposed. As a result, the GelMA hydrogel coatings are beneficial to the application of MAO-coated magnesium alloys in bone tissue engineering and other fields.