The end-Permian mass extinction was the largest biotic crisis in the history of animal life, eliminating as many as 95% of all species and dramatically altering the ecological structure of marine communities. Although the causes of this pronounced ecosystem shift have been widely debated, the broad consensus based on inferences from global taxonomic diversity patterns suggests that the shift from abundant brachiopods to dominant molluscs was abrupt and largely driven by the catastrophic effects of the end-Permian mass extinction. Here we analyze relative abundance counts of >33,000 fossil individuals from 24 silicified Middle and Late Permian paleocommunities, documenting a substantial ecological shift to numerical dominance by molluscs in the Late Permian, before the major taxonomic shift at the end-Permian mass extinction. This ecological change was coincident with the development of fluctuating anoxic conditions in deep marine basins, suggesting that numerical dominance by more tolerant molluscs may have been driven by variably stressful environmental conditions. Recognition of substantial ecological deterioration in the Late Permian also implies that the end-Permian extinction was the climax of a protracted environmental crisis. Although the Late Permian shift to molluscan dominance was a pronounced ecological change, quantitative counts of 847 Carboniferous-Cretaceous collections from the Paleobiology Database indicate that it was only the first stage in a stepwise transition that culminated with the final shift to molluscan dominance in the Late Jurassic. Therefore, the ecological transition from brachiopods to bivalves was more protracted and complex than their simple Permian-Triassic switch in diversity.