Background: Next generation of coating materials on the surface of implants is designed with a paradigm shift from an inert material to an osteoimmunomodulatory material. Regulating immune response to biomedical implants through influencing the polarization of macrophage has been proven to be an effective strategy. Methods: Through anodization and hydrothermal treatment, magnesium ion incorporated TiO 2 nanotube array (MgN) coating was fabricated on the surface of titanium and it is hypothesized that it has osteoimmunomodulatory properties. To verify this assumption, systematic studies were carried out by in vitro and in vivo experiments. Results: Mg ion release behavior results showed that MgN coating was successfully fabricated on the surface of titanium using anodization and hydrothermal technology. Scanning electron microscopy (SEM) images showed the morphology of the MgN coating on the titanium. The expression of inflammation-related genes (IL-6, IL-1β, TNF-α) was downregulated in MgN group compared with TiO 2 nanotube (NT) and blank Ti groups, but anti-inflammatory genes (IL-10 and IL-1ra) were remarkably upregulated in the MgN group. The in vitro and in vivo results demonstrated that MgN coating influenced macrophage polarization toward the M2 phenotype compared with NT and blank-Ti groups, which enhanced osteogenic differentiation of rat bone mesenchymal stem cells rBMSCs in conditioned media (CM) generated by macrophages. Conclusion: MgN coating on the titanium endowed the surface with immune-regulatory features and exerted an advantageous effect on osteogenesis, thereby providing excellent strategies for the surface modification of biomedical implants.