The loss of biodiversity has become a matter of urgent concern and a better understanding of local drivers is crucial for conservation. Although environmental heterogeneity is recognized as an important determinant of biodiversity, this has rarely been tested using field data at management scale. We propose and provide evidence for the simple hypothesis that local species diversity is related to spatial environmental heterogeneity. Species partition the environment into habitats. Biodiversity is therefore expected to be influenced by two aspects of spatial heterogeneity: 1) the variability of environmental conditions, which will affect the number of types of habitat, and 2) the spatial configuration of habitats, which will affect the rates of ecological processes, such as dispersal or competition. Earlier, simulation experiments predicted that both aspects of heterogeneity will influence plant species richness at a particular site. For the first time, these predictions were tested for plant communities using field data, which we collected in a wooded pasture in the Swiss Jura mountains using a four-level hierarchical sampling design. Richness generally increased with increasing environmental variability and "roughness" (i.e. decreasing spatial aggregation). Effects occurred at all scales, but the nature of the effect changed with scale, suggesting a change in the underlying mechanisms, which will need to be taken into account if scaling up to larger landscapes. Although we found significant effects of environmental heterogeneity, other factors such as history could also be important determinants. If a relationship between environmental heterogeneity and species richness can be shown to be general, recently available high-resolution environmental data can be used to complement the assessment of patterns of local richness and improve the prediction of the effects of land use change based on mean site conditions or land use history.