Most mass extinctions during the last 500 m.y. coincide with eruptions of large igneous provinces (LIPs). The Cretaceous-Tertiary extinction was synchronous with the Deccan flood volcanism, the Permian-Triassic extinction with the eruption of the enormous Siberian traps, and the end-Guadalupian extinction with the Emeishan volcanic province. The causal link remains disputed, however, and many LIPs apparently had no significant impact on the biosphere. Here we show that a key control on the destructive consequences of LIP emplacement is the type of sedimentary rock in basins beneath the flood basalts. Contact metamorphism around intrusions in dolomite, evaporite, coal, or organic-rich shale generates large quantities of greenhouse and toxic gases (CO2, CH4, SO2), which subsequently vent to the atmosphere and cause global warming and mass extinctions. The release of sediment-derived gases had a far greater impact on the environment than the emission of magmatic gases.