Changes in precipitation patterns induced by global climate change have profound implications for the structure and function of grassland ecosystems. However, the relationship between plant diversity and ecosystem function across different grassland types, particularly those with varying plant compositions and dominant species, remains inadequately understood. To address this knowledge gap, a five-year experimental manipulation of precipitation was conducted within herbaceous and shrub communities in the desert grasslands of Inner Mongolia. We found that increased precipitation significantly enhances aboveground biomass (AGB), belowground biomass (BGB), and community total biomass (CTB) in both herbaceous and shrub communities. In herbaceous communities, increased precipitation led to a disproportionate increase in both aboveground and belowground biomass, supporting the optimal allocation hypothesis. Structural equation modeling (SEM) further elucidated that precipitation regulates AGB and CTB through species richness and functional traits in herbaceous communities. In shrub communities, precipitation influences AGB, BGB, and CTB by affecting species richness and soil water content. This study highlights the critical role of precipitation in shaping biomass dynamics and allocation strategies within herbaceous and shrub communities in desert steppe of Inner Mongolia. These findings provide essential insights into the potential responses of desert grassland ecosystems to ongoing climate change.