Magnesium (Mg) and its alloys have attracted increasing attention in recent years as medical implants for repairing musculoskeletal injuries because of their promising mechanical and biological properties. However, rapid degradation of Mg and its alloys in physiological fluids limited their clinical translation because the accumulation of hydrogen (H2) gas and fast release of OH- ions could adversely affect the healing process. Moreover, infection is a major concern for internally implanted devices because it could lead to biofilm formation, prevent host cell attachment on the implants, and interfere osseointegration, resulting in implant failure or other complications. Fabricating nanostructured magnesium oxide (MgO) on magnesium (Mg) substrates is promising in addressing both problems because it could slow down the degradation process and improve the antimicrobial activity. In this study, nanostructured MgO layers were created on Mg substrates using two different surface treatment techniques, i.e., anodization and electrophoretic deposition (EPD), and cultured with Staphylococcus aureus in vitro to determine their antimicrobial properties. At the end of the 24-h bacterial culture, the nanostructured MgO layers on Mg prepared by anodization or EPD both showed significant bactericidal effect against S. aureus. Thus, nanostructured MgO layers on Mg are promising for reducing implant-related infections and complications and should be further explored for clinical translation toward antimicrobial biodegradable implants.