The West Antarctic ice sheet (WAIS), with ice volume equivalent to ~5m of sea level, has long been considered capable of past and future catastrophic collapse. Today, the ice sheet is fringed by vulnerable floating ice shelves that buttress the fast flow of inland ice streams. Grounding lines are several hundred metres below sea level and the bed deepens upstream, raising the prospect of runaway retreat. Projections of future WAIS behaviour have been hampered by limited understanding of past variations and their underlying forcing mechanisms. Its variation since the Last Glacial Maximum is best known, with grounding lines advancing to the continental-shelf edges around ~15kyr ago before retreating to near-modern locations by ~3kyr ago. Prior collapses during the warmth of the early Pliocene epoch and some Pleistocene interglacials have been suggested indirectly from records of sea level and deep-sea-core isotopes, and by the discovery of open-ocean diatoms in subglacial sediments. Until now, however, little direct evidence of such behaviour has been available. Here we use a combined ice sheet/ice shelf model capable of high-resolution nesting with a new treatment of grounding-line dynamics and ice-shelf buttressing to simulate Antarctic ice sheet variations over the past five million years. Modelled WAIS variations range from full glacial extents with grounding lines near the continental shelf break, intermediate states similar to modern, and brief but dramatic retreats, leaving only small, isolated ice caps on West Antarctic islands. Transitions between glacial, intermediate and collapsed states are relatively rapid, taking one to several thousand years. Our simulation is in good agreement with a new sediment record (ANDRILL AND-1B) recovered from the western Ross Sea, indicating a long-term trend from more frequently collapsed to more glaciated states, dominant 40-kyr cyclicity in the Pliocene, and major retreats at marine isotope stage 31 (~1.07Myr ago) and other super-interglacials.