A central theory of community ecology is that increased biodiversity results in greater ecosystem function and stability. Many experiments have examined biodiversity-ecosystem function (BEF) relationships at the primary producer level, yet BEF relationships are equally pertinent at higher trophic levels. In seagrass ecosystems, mesograzers (small invertebrate herbivores) promote seagrass persistence by consuming competitively superior epiphytic algae that foul seagrass blades. Experiments in seagrass habitat suggest that mesograzer diversity is a primary driver of top-down control of epiphytic algae, but also that the relationship is temporally and spatially variable. The primary hypothesis of my study is that much of this variability may be due to differences in seagrass habitat structure through time and space. I worked in eelgrass (Zostera marina) habitat in San Diego Bay, California, USA, to test whether variability in eelgrass structural complexity (shoot density) affects relationships between mesograzer biodiversity and ecosystem function (grazing impact and secondary production). I also examined the functional roles of numerically dominant eelgrass epifauna, using a laboratory experiment and stable isotope analysis. Contrary to BEF theory, increased grazer diversity in laboratory mesocosms resulted in decreased grazing impact and facilitation of algal growth. Though some species combinations resulted in increased algal grazing, antagonistic relationships among the most influential grazing taxa resulted in reduced ecosystem function. Structural complexity promoted mesograzer top-down control of epiphytes, increased mesograzer secondary production, and altered epifaunal community composition. Effects of biodiversity and structural complexity on grazing corresponded to variability in diet and feeding behavior among dominant epifaunal taxa. My results demonstrate the importance of examining species-specific interactions when considering links between community structure and ecosystem function, and that environmental context, such as habitat structure, may have large effects on BEF relationships.