We know little about how ecosystems of different complexity will respond to global warming(1-5). Microcosms permit experimental control over species composition and rates of environmental change. Here we show using microcosm experiments that extinction risk in warming environments depends on trophic position but remains unaffected by biodiversity. Warmed communities disproportionately lose top predators and herbivores, and become increasingly dominated by autotrophs and bacterivores. Changes in the relative distribution of organisms among trophically defined functional groups lead to differences in ecosystem function beyond those expected from temperature-dependent physiological rates. Diverse communities retain more species than depauperate ones, as predicted by the insurance hypothesis, which suggests that high biodiversity buffers against the effects of environmental variation because tolerant species are more likely to be found(6,7). Studies of single trophic levels clearly show that warming can affect the distribution and abundance of species(2,4,5), but complex responses generated in entire food webs greatly complicate inferences based on single functional groups.