Exotic species Spartina alterniflora (S. alterniflora) are widely invaded in the coastal zones of China and threaten the native ecosystem functions. In this study, phosphorus-magnesium modified BC (P-Mg modified BC) included PA-Mg-BC and DAP-Mg-BC derived from S. alterniflora were successfully prepared by co-pyrolysis of biomass and diammonium phosphate (DAP) or phosphoric acid (PA) and magnesium oxide (MgO). The preparation process markedly improved the surface morphologies, P loading amount, and P-containing functional groups of modified BC. The characterization results indicated that stable and low-solubility Mg-P complex formed on the surface of PA-Mg-BC and DAP-Mg-BC, which delayed the rapid release of P. Moreover, the MgO improved the buffering capacity of PA-Mg-BC and DAP-Mg-BC to competitive anions (SO42- and CO32-) during P release. Meanwhile, pot experiment showed that the suitable applications of PA-Mg-BC and DAP-Mg-BC could improve soil quality and fertility by enhancing SOC, DOC, TN, TP and AP contents, as well as beta-glucosidase activities. The amended soil pH and salinity compared to the original soil also declined through precipitation and acid-base neutralization. In addition, P-Mg modified BC could improve bacterial community structure and promote the growth and biomass of Suaeda salsa (S. salsa). This study could provide a feasible method for realizing ecological restoration of coastal wetland and resource utilization of S. alterniflora.