Hydroxyapatite (HA), chitosan (CS), ZrO2 and MgO suspensions were distributed by zonal electrophoresis (ZE), and then HA/CS/ZrO2/MgO composite coating on the surface of titanium substrate was fabricated by electrophoretic deposition (EPD) in a reverse electric field subsequently. An HA/ZrO2/MgO gradient composite coating (Z1) was fabricated by calcination at 700 °C for 120 min. At the same time, another HA/ZrO2/MgO composite coating (E1) was directly fabricated only by electrophoretic deposition for comparison, where ZrO2 and MgO were osteogenic trace element compounds (OTECs). The morphology, structure, composition, wettability, apatite-forming ability, antibacterial efficacy of the composite coating Z1 were investigated by XRD, FT-IR, FESEM, EDS, contact angle goniometry, Lloyd's universal testing machine, electrochemical workstation, immersing in simulated body fluid, and inhibition experiments. The results showed that the contents of Ca, Zr, and Mg elements had a gradient distribution in direction of coating thickness. With the addition of ZrO2 and MgO, the contact angle of Z1 is significantly reduced from 52.5° to 27.3°. Remarkably, Z1 has more improved properties than E1, mainly manifested in the bonding strength of Z1 and titanium substrate up to 29.3 MPa, exceeding the standard requirements for bonding strength of HA coating implants (15 Mpa, iso13779-2) and as can be observed from cyclic voltammetry (CV) curve and Tafel polarization curve, Z1 exhibit superior electrochemical stability and strong corrosion resistance when immersed in HEPES simulated body fluid (H–SBF). In addition, after immersing in H–SBF for 24 d, the surface of the Z1 was completely covered by carbonated hydroxyapatite (CHA) and the Ca/P of the coating increased from 1.67 to 1.99. Furthermore, the antibacterial effect test of Z1 showed that the antibacterial rates of Z1 against Escherichia coli and Staphylococcus aureus reached to 98.2 % and 86.3 %, respectively.