Environmental heterogeneity contributes to coexistence by allowing species with different traits to persist when different species perform best at different times or places. This interaction between niche differences and environmental variability may also help explain relationships between biodiversity and ecosystem functioning, but few data are available to rigorously evaluate this hypothesis. We assessed how a biologically relevant aspect of environmental heterogeneity interacts with species diversity to determine ecosystem processes in a natural rocky intertidal community. We used field removals to factorially manipulate biogenic habitat heterogeneity (barnacles, bare rock, and plots that were 50/50 mixes of the two habitat types) and gastropod grazer species richness and then tracked algal community succession and recovery over the course of 1 yr. We found that herbivore diversity, substrate heterogeneity, and their interaction played unique roles in the peak abundance and timing of occurrence of different algal functional groups. Early successional microalgae were most heavily grazed in diverse herbivore assemblages and those with barnacles present, which was likely due to complementary feeding strategies among all three grazers. In contrast, late successional macroalgae were strongly influenced by the presence of a habitat generalist limpet. In this herbivore's absence, heterogeneous habitats (i.e., mixtures of bare rock and barnacles) experienced the greatest algal accumulation, which was partly a result of complementary habitat use by the remaining herbivores. The complex way habitat identity and heterogeneity altered grazer-algal interactions in our study suggests species' differences and environmental heterogeneity both separately and interactively contribute to the relationship between biodiversity and ecosystem functions.