Herein, Mg/Al-loaded sludge-based biochar was prepared via electro-assisted impregnation. The structure and chemical analysis of modified sludge-based biochar (MgSBC-0.5(@Al) showed that the material was loaded with MgO and Al2O3. The specific surface area of MgSBC-0.5(@Al) was 11.27 times higher than that of unmodified sludge-based biochar (SBC). The simultaneous adsorption performance of MgSBC-0.5(@Al for ammonia nitrogen (NH4+-N) and phosphate phosphorus (PO43--P) was studied. The maximum adsorption capacities of MgSBC-0.5(@Al for NH4+-N and PO43--P at 298 K were 65.19 and 92.10 mg·g-1, respectively, 4.45 and 6.28 times higher than those of SBC. The external and internal elemental compositions of the modified and unmodified biochar specimens were quantitatively characterized using inductively coupled plasma mass spectrometry, X-ray photoelectron spectroscopy, and X-ray fluorescence spectrometry. The results emphasized the importance of Mg-loading for NH4+-N and PO43--P capture. MgO was mainly loaded on the surface of biochar, enabling adsorption through chemical reactions. Analysis showed that the adsorption of NH4+-N and PO43--P on the modified biochar proceeded simultaneously through multiple mechanisms. Particularly, the adsorption of NH4+-N and PO43--P occurred through the precipitation of struvite and physical adsorption, with PO43--P also adsorbed through the formation of MgHPO4 and CaHPO4. Other data indicated that Al, Ca, and Fe had a trapping effect on the adsorbate. Importantly, the biochar after adsorption could be used as a soil amendment.