Understanding the mechanisms underlying diversity-biomass relationships (DBRs) under hydrological stress is particularly valuable for predicting how increased flooding will impact biodiversity and ecosystem functions. However, it remains unclear how dam-induced extreme flooding influences the biodiversity effect on aboveground biomass (AGB) and belowground biomass (BGB) in riparian ecosystems, and how plant traits and edaphic factors mediate this influence. Here, we surveyed plant diversity, plant traits, AGB, and BGB in 321 quadrats at 107 transects along the hydrological gradients in the Three Gorges riparian zones. We employed structure equation models (SEM) to elucidate the causal mechanisms among flooding, plant diversity, functional traits, soil nutrients, and biomass. We found that AGB was positively associated with the community-weighted means of plant height, leaf length, and leaf dry matter content, as well as the functional dispersion of leaf length, suggesting the simultaneous occurrence of positive selection and complementarity effects. Conversely, BGB was positively associated with species richness, Shannon diversity, and Simpson diversity, highlighting the importance of species complementarity for BGB. Moreover, our SEM explained 17%-47% of AGB and 18%-33% of BGB, with greater explanatory power at the transect scale than the quadrat scale. At both scales, increased flooding stresses directly reduced AGB and BGB, while plant traits (e.g., plant height and leaf dry matter content) and soil nutrients primarily mediated the effects of flooding on AGB and BGB, respectively. Our findings reveal distinct mechanisms driving DBRs for AGB and BGB, highlighting that DBRs are enhanced in habitats with greater heterogeneity shaped by dam-induced hydrological changes.