As biodiversity is declining at an unprecedented rate, an important current scientific challenge is to understand and predict the consequences of biodiversity loss. Here we develop a theory that predicts the temporal variability of community biomass from the properties of individual component species in monoculture. Our theory shows that biodiversity stabilises ecosystems through three main mechanisms: (1) asynchrony in species’ responses to environmental fluctuations, (2) reduced demographic stochasticity due to overyielding in species mixtures, and (3) reduced observation error (including spatial and sampling variability). Parameterized with empirical data from four long-term grassland biodiversity experiments, our prediction explained 22–75% of the observed variability, and captured much of the effect of species richness. Richness stabilized communities mainly by increasing community biomass and reducing the strength of demographic stochasticity. Our approach calls for a re-evaluation of the mechanisms explaining the effects of biodiversity on ecosystem stability.