The decomposition of dead organic matter is a major determinant of carbon and nutrient cycling in ecosystems, and of carbon fluxes between the biosphere and the atmosphere. Decomposition is driven by a vast diversity of organisms that are structured in complex food webs. Identifying the mechanisms underlying the effects of biodiversity on decomposition is critical given the rapid loss of species worldwide and the effects of this loss on human well-being. Yet despite comprehensive syntheses of studies on how biodiversity affects litter decomposition, key questions remain, including when, where and how biodiversity has a role and whether general patterns and mechanisms occur across ecosystems and different functional types of organism. Here, in field experiments across five terrestrial and aquatic locations, ranging from the subarctic to the tropics, we show that reducing the functional diversity of decomposer organisms and plant litter types slowed the cycling of litter carbon and nitrogen. Moreover, we found evidence of nitrogen transfer from the litter of nitrogen-fixing plants to that of rapidly decomposing plants, but not between other plant functional types, highlighting that specific interactions in litter mixtures control carbon and nitrogen cycling during decomposition. The emergence of this general mechanism and the coherence of patterns across contrasting terrestrial and aquatic ecosystems suggest that biodiversity loss has consistent consequences for litter decomposition and the cycling of major elements on broad spatial scales.