When nearly every dinosaur went extinct 66 million years ago, the only ones that survived were those that had shrunk—that is, the birds. Today, there are 10,000 species of these feathered fliers, making them the most diverse of all the four-limbed animals. A new study reveals why this lineage has been so successful: Birds started downsizing well before the rest of the dinosaurs disappeared.

“This is a very impressive piece of work and by far the most comprehensive analysis of dinosaur body size that has been conducted,” says Stephen Brusatte, a paleontologist at the University of Edinburgh in the United Kingdom, who was not involved in the research. “The study shows that birds didn’t just become small suddenly, but were the end product of a long-term trend of body size decline that took many tens of millions of years.”

Dinosaurs were small in the beginning. About 230 million years ago, most weighed between 10 and 35 kilograms and were as big as a medium-sized dog. But many species soon soared to tractor-trailer proportions, reaching 10,000 kilograms within 30 million years. Later on, dinosaurs like the mighty Argentinosaurus, which stretched some 35 meters from nose to tail, weighed in at a staggering 90,000 kilograms.

Although many dinosaurs were getting bigger and bulkier over millions of years, one group seems to have hedged its bets on body size: the maniraptorans, feathered dinos that include Velociraptor of Jurassic Park fame and that eventually gave rise to the birds. To pin down how dinosaur size changed over time, a team led by Roger Benson, a paleontologist at the University of Oxford in the United Kingdom, estimated the body size of 426 different species, using the thickness of their fossilized hind leg bones as a proxy for their overall weight.

The team found that although all dinosaur groups rapidly changed size at the beginning of dinosaur evolution—primarily by getting bigger—that trend slowed down fairly quickly in almost all groups. For the most part, the dinos that got big stayed that way. The exception was the maniraptorans, which continued to evolve bigger and smaller species as they expanded into an ever wider variety of ecological niches over a period of 170 million years.

When an asteroid hit Earth 66 million years ago, only those feathered maniraptorans that had downsized to about 1 kilogram or so—the birds—were able to survive, probably because their small size allowed them to adapt more easily to changing conditions, the team concludes online today in PLOS Biology. The researchers argue that being small made it easier for maniraptorans to adapt to a wider variety of habitats, whereas the rest of the dinosaurs, encumbered by their huge bodies and enormous food requirements, simply didn’t make it.

This size reduction was essential for the evolution of flight, says Luis Chiappe, a paleontologist at the Natural History Museum of Los Angeles County in California, who was not involved in the study. “Flight is easier for smaller animals” because it is “a lot less energetically demanding,” he says. And during all those millions of years when maniraptorans were changing body size more quickly than other dinos, Chiappe says, “they were experimenting with various degrees of birdness.”

“The really interesting story,” Brusatte adds, “isn’t so much to do with how some dinosaurs got so huge, but rather how birds and their close relatives got so small.”