Calcium phosphate (CaP) coatings have been widely studied as a biocompatible coating on biodegradable magnesium (Mg) alloys to improve the corrosion resistance and bioactivity for orthopedic application. However, the porous structure of CaP coatings formed in the aqueous solution cannot achieve the ideal long-time corrosion resistance. In this work, a titania (TiO2) coating was prepared on the hydroxyapatite (HA) coated Mg alloy by a sol-gel method. The in vitro degradation results of electrochemical measurements and immersion test show that the corrosion resistance of HA coated Mg alloy was further improved by the TiO2 sol-gel coatings. Furthermore, a systematic investigation of in vitro cytocompatibility and antibacterial properties of the samples was performed. The composite coating significantly enhanced cell adhesion and growth compared to the HA coating and uncoated Mg alloy. Meanwhile, the result of plate-counting method demonstrates that the antibacterial rate of the composite coating against E. coil and S.aureus reached 99.5 +/- 0.3% and 99.8 +/- 0.2%, respectively. These results suggest that the HA/TiO2 composite coatings effectively enhanced the corrosion resistance, in vitro cytocompatibility and antibacterial properties of Mg alloy and porous CaP-based coating, potentially widening the application of Mg alloys in the biomedical field. (C) 2018 The Electrochemical Society.