In recent decades, intensive research on non-avian dinosaurs has strongly suggested that these animals were restricted to terrestrial environments1. Historical proposals that some groups, such as sauropods and hadrosaurs, lived in aquatic environments2,3 were abandoned decades ago4,5,6. It has recently been argued that at least some of the spinosaurids—an unusual group of large-bodied theropods of the Cretaceous era—were semi-aquatic7,8, but this idea has been challenged on anatomical, biomechanical and taphonomic grounds, and remains controversial9,10,11. Here we present unambiguous evidence for an aquatic propulsive structure in a dinosaur, the giant theropod Spinosaurus aegyptiacus7,12. This dinosaur has a tail with an unexpected and unique shape that consists of extremely tall neural spines and elongate chevrons, which forms a large, flexible fin-like organ capable of extensive lateral excursion. Using a robotic flapping apparatus to measure undulatory forces in physical models of different tail shapes, we show that the tail shape of Spinosaurus produces greater thrust and efficiency in water than the tail shapes of terrestrial dinosaurs and that these measures of performance are more comparable to those of extant aquatic vertebrates that use vertically expanded tails to generate forward propulsion while swimming. These results are consistent with the suite of adaptations for an aquatic lifestyle and piscivorous diet that have previously been documented for Spinosaurus7,13,14. Although developed to a lesser degree, aquatic adaptations are also found in other members of the spinosaurid clade15,16, which had a near-global distribution and a stratigraphic range of more than 50 million years14, pointing to a substantial invasion of aquatic environments by dinosaurs.