It is well understood that biodiversity is often important for ecosystem functioning but most of the empirical work has taken place on small spatial and temporal scales. Therefore, we need to improve our understanding at larger spatial and temporal scales if we want biodiversity-ecosystem functioning science to be relevant for policy and management. We built a methodological pipeline around a rigorously derived statistical partition that allowed us to distinguish the various ways in which biodiversity can affect functioning in two natural marine ecosystems (intertidal rockpool macroalgae and marine fouling communities). This partitioning considers both local species interactions and species' asynchronous responses to varying environments over space and time. We found evidence that a combination of local-scale species interactions, local-scale dominance by high functioning species and spatial niche partitioning contributed to a positive effect of biodiversity on ecosystem functioning in these ecosystems. Moreover, the effect of spatial niche partitioning tended to strengthen with increasing spatial environmental heterogeneity. Our approach allowed us to directly quantify the complex ways in which biodiversity can affect ecosystem functioning and highlights the importance of taking a multi-scale perspective in biodiversity-ecosystem functioning research.