Biodegradable magnesium alloys are advantageous in various implant applications, as they reduce the risks associated with permanent metallic implants. However, a rapid corrosion rate is usually a hindrance in biomedical applications. Here we report a facile two step procedure to introduce multifunctional, anti-corrosive coatings on Mg alloys, such as AZ31. The first step involves treating the NaOH-activated Mg with bistriethoxysilylethane to immobilize a layer of densely crosslinked silane coating with good corrosion resistance; the second step is to impart amine functionality to the surface by treating the modified Mg with 3-amino-propyltrimethoxysilane. We characterized the two-layer anticorrosive coating of Mg alloy AZ31 by Fourier transform infrared spectroscopy, static contact angle measurement and optical profilometry, potentiodynamic polarization and AC impedance measurements. Furthermore, heparin was covalently conjugated onto the silane-treated AZ31 to render the coating haemocompatible, as demonstrated by reduced platelet adhesion on the heparinized surface. The method reported here is also applicable to the preparation of other types of biofunctional, anti-corrosive coatings and thus of significant interest in biodegradable implant applications.