A major shake-up of the dinosaur family tree has overturned 130 years of thinking about "terrible lizard" evolution.
Until now, dinosaurs have been divided into two major groups, or clades, according to whether they have bird-like or lizard-like hips.
Yet birds are known to have evolved from theropods - meat-eating dinosaurs belonging to the "lizard-hip" category which included Tryrannosaurus rex.
The new family tree resolves this problem by grouping theropods and bird-hipped dinosaurs together.
Dr David Norman, one of the study authors from Cambridge University, said: "The repercussions of this research are both surprising and profound.
"The bird-hipped dinosaurs, so often considered paradoxically named because they appeared to have nothing to do with bird origins, are now firmly attached to the ancestry of living birds."
The new analysis, published in the journal Nature, suggests that the earliest dinosaurs were small omnivorous creatures that walked on two legs and had grasping hands.
It also challenges the common view that dinosaurs originated in the southern hemisphere on the ancient continent known as Gondwana.
Dinosaurs were first recognised as a unique group of fossil reptiles in 1842 as a result of the work of Professor Richard Owen, founder of London's Natural History Museum.
They were later divided into two main "clades", the bird-hipped ornithischia and lizard-hipped saurischia. Ornithischia included the plant-eating iguanodon, triceratops and stegosaurus. Saurischia included giant sauropod herbivores such as diplodocus, but also carnivorous theropods.
To re-organise the dinosaur family tree, the scientists looked at 74 families of early dinosaurs, analysing 457 key anatomical characteristics.
They identified two main branches, one of which gave rise to both the theropods and ornithischia, now organised into a new group named the ornithoscelida.
The other branch led to a separate group containing the sauropods and early carnivores known as herrerasaurs.
Co-author Professor Paul Barrett, from the Natural History Museum, said: "This study radically redraws the dinosaur family tree, providing a new framework for unravelling the evolution of their key features, biology and distribution through time."
The new analysis shows that both ornithischians and theropods had the potential to evolve a bird-like hip arrangement at different times in their history.