Rechargeable magnesium (Mg) batteries assembled with dendrite-free, safe, and earth-abundant metal Mg anodes potentially have the advantages of high theoretical specific capacity and energy density. Nevertheless, owing to the large polarity of divalent Mg2+ ions, the insertion of Mg2+ into electrode materials suffers from sluggish kinetics, which seriously limit the performance of Mg batteries. Herein, we demonstrate an atomic substitution strategy for the controlled preparation of ultrathin black TiO2- x (B-TiO2- x) nanoflakes with rich oxygen vacancies (OVs) and porosity by utilizing ultrathin 2D TiS2 nanoflakes as precursors. We find out that the presence of OVs in B-TiO2- x electrode material can greatly improve the electrochemical performances of rechargeable Mg batteries. Both experimental results and density functional theory simulations confirm that the introduction of OVs can remarkably enhance the electrical conductivity and increase the number of active sites for Mg2+ ion storage. The vacancy-rich B-TiO2- x nanoflakes exhibit high reversible capacity and good capacity retention after long-term cycling at large current densities. It is hoped that this work can provide valuable insights and inspirations on the defect engineering of electrode materials for rechargeable magnesium batteries.