Hundreds of studies that have explored how biodiversity affects the productivity and stability of ecosystems have produced a consensus that communities composed of more species tend to have higher biomass that is more stable through time. However, the majority of this work stems from studies performed using highly simplified food webs, often composed of just primary producers competing for inorganic resources in the absence of trophic interactions. When studies have incorporated trophic interactions, diversity-function relationships have been more variable, leaving open the question of how biodiversity affects the functioning of ecosystems with more trophic levels. Here we report the results of a laboratory experiment that used freshwater microcosms to test for effects of algal diversity (one or four species) on community biomass and temporal variability in the presence and absence of two different herbivore species (cladocerans Ceriodaphnia dubia and Daphnia pulex). When no herbivores were present, we found the classic pattern observed in hundreds of other studies – as species richness of algae increased, algal biomass increased, and the temporal variation in biomass decreased. This pattern was retained when one of the herbivores (C. dubia) was present. Ceriodaphnia dubia exhibited weak and non-selective grazing on the focal algae, leaving the effect of diversity on biomass and variability essentially intact. In contrast, D. pulex exhibited strong and selective grazing in algal polycultures that qualitatively altered both diversity–function relationships. As algal richness increased, total algal biomass decreased and variation through time increased. These changes were coupled with larger and less variable populations of D. pulex. Our results show that herbivory leads to a richer array of diversity–function relationships than often observed in studies focused on just one trophic level, and suggests trophic interactions should be given more attention in work that seeks to determine how biodiversity impacts the functioning of ecosystems.