Intensive research on non-avian dinosaurs in recent decades strongly suggests that these animals were restricted to terrestrial environments 1. Historical views proposing that some groups, such as sauropods and hadrosaurs, lived in aquatic environments 2,3 were abandoned decades ago 4,5,6. Recently, however, it has been argued that at least some spinosaurids, an unusual group of large-bodied Cretaceous theropods, were semi-aquatic 7,8 , but this idea has been challenged on anatomical, biomechanical, and taphonomic grounds and remains controversial 9,10,11. Here we present the first unambiguous evidence for an aquatic propulsive structure in a dinosaur, the giant theropod Spinosaurus aegyptiacus 7, 12. This dinosaur has a tail with an unexpected and unique shape consisting of extremely tall neural spines and elongate chevrons forming a large, flexible, fin-like organ capable of extensive lateral excursion. Using a robotic flapping apparatus to measure undulatory forces in physical tail models, we show that the tail shape of Spinosaurus produces greater thrust and efficiency in water than the tail shapes of terrestrial dinosaurs, comparable to that of extant aquatic vertebrates that use vertically expanded tails to generate forward propulsion while swimming. This conclusion is consistent with a suite of adaptations for an aquatic lifestyle and a piscivorous diet in Spinosaurus 7,13,14. Although developed to a lesser degree, aquatic adaptations are also found in other spinosaurids 15,16 , a clade with a near global distribution and a stratigraphic range of more than 50 million years 14 , documenting a significant invasion of aquatic environments by dinosaurs.