The confinement of nano-MgO within magnetic biochar represents a promising strategy to enhance phosphate (P) adsorption performance. Nevertheless, the inherent agglomeration tendency of MgO within magnetic biochar has been identified as a significant impediment to its P adsorption efficiency. In this study, the nano-MgO was confined within magnetic biochar via a novel two-step pyrolysis process involving KHCO3 and HNO3 activation. This novel fabrication process resulted in a reduction in pore size and an increase in the negatively charged surface, facilitating the controlled formation of nano-MgO. The results demonstrated a uniform dispersion of nano-MgO crystals, with their size reduced to less than 10 nm. The P adsorption capacity reached 83.06 mg/g, which was 2.98 times higher than that of biochar via one-step pyrolysis. The mechanism study suggested that the chemical reaction was the driving force in P adsorption on biochar. Collectively, this research provides a feasible path to the successful confinement of nano-MgO in magnetic biochar, resulting in enhanced P adsorption performance.