This study employed spectroscopy, metagenomics, and molecular simulation to investigate the inhibitory effects of Cd(II) and Cu(II) on the anammox system, examining both intracellular and extracellular effects. At concentrations of 5 mg/L, Cd(II) and Cu(II) significantly reduced nitrogen removal efficiency by 41.46 % and 62.03 %, respectively. Additionally, elevated metal concentrations were correlated with decreased extracellular polymeric substances (EPS), thereby reducing their capacity to absorb heavy metals, particularly Cu(II), which decreased from 76.47 % to 14.67 %. Spectral analysis revealed alterations in the secondary structures of EPS induced by Cd(II) and Cu(II), decreasing the ratio of extracellular protein α-helix to (β-sheet + random coil), which resulted in looser extracellular protein configurations. The results of the metagenomics study showed that the abundance of Candidatus Kuenenia and its genes encoding nitrogen removal-related enzymes was reduced. The abundance of hzs-γ was reduced by 35.09 % at a concentration of 5 mg/L Cu(II). Conversely, genes associated with metal efflux enzymes, like czcR, increased by 54.86 % at 2 mg/L Cd(II). Molecular docking revealed robust bindings of Cd(II) to HZS-α (−342.299 ± 218.165 kJ/mol) and Cu(II) to HZS-γ (−880.934 ± 55.526 kJ/mol). This study elucidated the inhibitory mechanisms of Cd(II) and Cu(II) on the anammox system, providing insights into the resistance of anammox bacteria to heavy metals.