This study demonstrated a novel process configuration for sustaining mainstream anammox by integrating the anammox and endogenous partial denitrification-and-phosphorus removal (EPDPR) in two-stage sequencing batch reactors (SBRs). In the EPDPR-SBR, high nitrate-to-nitrite transformation (68.2%) and P removal (99.3%) were achieved by adjusting the anaerobic/anoxic/aerobic durations and influent nitrate concentration, providing a suitable NO2--N/NH4+-N (∼1.37) for subsequent anammox reaction. In the Anammox-SBR, ∼95% of TN was removed without external carbon and oxygen demands. Satisfactory effluent quality (∼6 mgTN/L and 0.2 mgP/L) achieved in the integrated EPDPR/anammox opens a new window towards the energy-efficient wastewater treatment. Microbial analysis further revealed that Dechloromonas (1.6-9.6%) and Candidatus Competibacter (6.4-5.8%) respectively conducted P removal and NO2--N production (79.2%) from NO3--N denitrification in the EPDPR-SBR, whereas Candidatus Kuenenia (7.0-29.7%) dominated NO2--N and NH4+-N removal (91.3% and 99.5%) in the Anammox-SBR, with 10 genera identified as denitrifying bacteria (0.6-8.1%) further reduced 18.9% of the produced NO3--N.