Advanced metal-doped biochar with superior phosphate (P) adsorption capacity plays a crucial role in combating eutrophication, depending on the rational design of the biochar structure for uniform and nanoscale dispersion of metal oxides. Herein, the nanoconfinement of magnesium oxide (MgO) was successfully attained in nitrogen pre-doped biochar (Mg/N-BC). The well-dispersed MgO was confined within nanoscale structure of Mg/N-BC, delivering P adsorption capacity of 108.41 mg g−1 and adsorption rate of 18.01 mg g-1h−1. More importantly, its adsorption performance at equilibrium 0.5 mg P/L was 17.70 times higher. Results suggested the decrease in pore size was positively correlated with the increase of N, confirming the role of N pre-doping in structure shaping and MgO confinement. The enhanced P adsorption was attributed to the well-dispersed MgO nanoparticles within the biochar. This study introduced a facile synthesis approach for biochar-incorporated nanoscale MgO, offering a new strategy for enhanced P removal.