Infection often causes disastrous consequences in all fields of clinical medicine, especially orthopedics. Hence, critical efforts are being made to engineer novel nanomaterials for the treatment of orthopedic infections due to the high biocompatibility and antibacterial properties they possess. The purpose of this study was to investigate the antibacterial effects of magnesium hydroxide (Mg(OH)2) nanoparticles (NPs) in vitro and determine their possible mechanisms of action. In this study, Escherichia coli was selected as the pathogenic bacteria and it was found that Mg(OH)2 NPs significantly inhibited the growth of E. coli by promoting nucleic acid leakage, inhibiting protein synthesis, and suppressing the metabolic activity. The minimum inhibitory concentration for these bacteria was determined to be 4.4 μg/ml. In vitro flow cytometry and immunofluorescence tests indicated that Mg(OH)2 NPs induced the macrophages to generate reactive oxygen species to kill the bacteria. To understand the mechanisms involved in this process, western blotting was performed and it was found that Mg(OH)2 NPs activated the phosphatidylinositol‐3‐kinase/serine–threonine kinase (PI3K/Akt) signaling pathway of macrophages to enhance their phagocytosis with no obvious cytotoxicity. Thus, Mg(OH)2 NPs are a suitable choice to develop promising agents or coating materials for the treatment of clinically widespread infections in view of their safety, biocompatibility, and powerful antibacterial properties.