Human-driven ecosystem simplification has highlighted questions about how the number of species in an ecosystem influences its functioning. Although biodiversity is now known to affect ecosystem productivity, its effects on stability are debated. Here we present a long-term experimental field test of the diversity-stability hypothesis. During a decade of data collection in an experiment that directly controlled the number of perennial prairie species, growing-season climate varied considerably, causing year-to-year variation in abundances of plant species and in ecosystem productivity. We found that greater numbers of plant species led to greater temporal stability of ecosystem annual aboveground plant production. In particular, the decadal temporal stability of the ecosystem, whether measured with intervals of two, five or ten years, was significantly greater at higher plant diversity and tended to increase as plots matured. Ecosystem stability was also positively dependent on root mass, which is a measure of perenniating biomass. Temporal stability of the ecosystem increased with diversity, despite a lower temporal stability of individual species, because of both portfolio (statistical averaging) and overyielding effects. However, we found no evidence of a covariance effect. Our results indicate that the reliable, efficient and sustainable supply of some foods (for example, livestock fodder), biofuels and ecosystem services can be enhanced by the use of biodiversity.