The use of magnesium ion (Mg 2+ )-modified biomaterials in bone regeneration is a promising and cost-effective therapeutic. Despite the widespread observation on the osteogenic effects of Mg 2+ , the diverse roles played by Mg 2+ in the complex biological process of bone healing have not been systematically dissected. Here, we reveal a previously unknown biphasic mode of action of Mg 2+ in bone repair. In the early inflammation phase, Mg 2+ primarily targets the monocyte-macrophage lineage to promote their recruitment, activation, and polarization.We showed that an increase in extracellular Mg 2+ contributes to an upregulated expression of transient receptor potential cation channel member 7 (TRPM7) and a TRPM7-dependent influx of Mg 2+ in the monocyte-macrophage lineage, resulting in the cleavage and nuclear accumulation of TRPM7-cleaved kinase fragments (M7CKs). This then triggers the phosphorylation of Histone H3 at serine 10, in a TRPM7-dependent manner at the promoters of inflammatory cytokines like IL-8, leading to the formation of a pro-osteogenic immune microenvironment. In the later active repair/remodeling phase of bone healing, however, continued exposure of Mg 2+ and IL-8 leads to over activation of NF-κB signaling in macrophages, turning the immune microenvironment into pro-osteoclastogenesis. Moreover, the presence of Mg 2+ at this stage also decelerates bone maturation through the suppression of hydroxyapatite precipitation. The negative effects of Mg 2+ on osteogenesis can override the initial pro-osteogenic benefits of Mg 2+ , as we found prolonged delivery of Mg 2+ compromises overall bone formation. Taken together, this study establishes a paradigm shift in understanding the diverse and multifaceted roles of Mg 2+ in bone healing.