The role of metal resistance on nitrogen metabolism function and community resilience against Cd is important for elucidating the evolutionary dynamics of key ecological functions in river ecosystems. In this study, the response of nitrogen transforming function to Cd exposure in river sediments from the Yangtze River Basin with varying levels of heavy metal contamination history (Cd-contaminated and Cd-free sediments) was compared to understand how Cd influenced nitrogen metabolism under varying metal resistance conditions. The results showed that chronic and persistent Cd pollution of sediments caused an elevation of transport efflux metal resistance genes (MRGs) and a reduction in the uptake MRGs, leading to a stronger tolerance to Cd for Cd-contaminated sediment than Cd-free ones. Specifically, denitrification, anaerobic ammonium oxidation (anammox) and dissimilatory nitrate reduction to ammonium (DNRA) respectively responded to Cd through different mechanisms. Exogenous Cd (5-100 mg kg