The performance of biodegradable magnesium alloy requires special attention to rapid degradation and poor biocompatibility, which can cause the implant to fail. Here, a sodium montmorillonite(MMT)/bovine serum albumin(BSA) composite coating was prepared upon magnesium alloy AZ31 via hydrothermal synthesis, followed by dip coating. We evaluated the surface characterization and corrosion behavior in vitro, and the biocompatibility in vitro and in vivo. Biodegradation progress of the MMT-BSA coated Mg pieces was examined through hydrogen evolution, immersion tests, and electrochemical measurements in Hank's solution. In vitro biocompatibility studies were evaluated via hemolysis tests, dynamic cruor time tests, platelet adhesion, MTT testing and live-dead stain of osteoblast cells(MC3 T3-E1). It was found that the MMT-BSA coating had good corrosion resistance and a marked improvement in biocompatibility in comparison to bare Mg alloy AZ31. in vivo studies were carried out in rat model and the degradation was characterized by computed tomography scans. Results revealed that the MMT-BSA coated Mg alloy AZ31 implants maintained their structural integrity and slight degradation after 120 d of post-implantation. A100% survival rate for the rats was observed with no obvious toxic damages on the organs and tissues.Additionally, we proposed a sound coating formation mechanism. Considering the good corrosion protection and biocompatibility, the MMT-BSA coated Mg alloy AZ31 is a promising candidate material for biomedical implants.