Crawling up a rocky outcrop in northeastern Montana in 2016, research scientist David DeMar, Jr., spotted a dark, reddish-brown nodule about half the size of a golf ball. He picked it up, scanned it through his hand lens, and couldn't believe his eyes: a tiny fossil feather, nested inside what would turn out to be 66-million-year-old dinosaur poop. It was the first feather ever found in the Hell Creek Formation, even after more than 150 years of prospecting.

That surprising discovery may help answer one of paleontology's biggest mysteries: Why did birds survive the asteroid that wiped out nearly everything else?

Birds are a highly specialized branch of the dinosaur family tree. The oldest known bird, Archaeopteryx, lived about 150 million years ago, and birds kept evolving alongside other dinosaurs for nearly another 100 million years. Then, 66 million years ago, an asteroid struck Earth and triggered a global extinction. Almost every dinosaur lineage vanished, including most types of birds. Only one branch, called Neornithes, survived — and it gave rise to every bird species alive today.

Scientists have long wondered why Neornithes endured. Jingmai O'Connor, the paper's lead author and associate curator of fossil reptiles at the Field Museum in Chicago, has spent years studying fossil birds. For this project, published in Current Biology, she went somewhere completely unexpected: inside fossilized dinosaur feces, known as coprolites.

"No one has ever thought to look for feathers or to study feathers in coprolites, so this project was really exciting," O'Connor said.

Back in the lab, researchers analyzed the fossil's mineral makeup and used micro-CT scanning — a technique that combines thousands of X-rays into a detailed 3D view without destroying the object. "Every hour processing the data revealed another feather, another scale, another bone — in stunning 3D," said co-author Nate Carroll, a paleontologist at the Carter County Museum in Ekalaka, Montana.

Inside the coprolite, the team identified several feathers, tiny scales from a gar fish, and leg bones of an aquatic bird called a hesperornithiform. Because the feathers and bones appeared together, they likely came from the same bird — one that was swallowed by a large dinosaur, possibly a T. rex or Nanotyrannus.

Hesperornithiforms were diving birds, ecologically similar to loons, that used their specialized feet to hunt fish underwater. Their feathers showed adaptations for diving that scientists see in living aquatic birds. Hesperornithiforms were close relatives of the surviving Neornithes branch, but they belonged to a separate lineage that disappeared with most other dinosaurs.

The research offers a tantalizing clue about the ancient world and raises a fresh question: was living near water enough to survive, or was something else at work? "It's such a beautiful, well-preserved feather, from such an unexpected source, and it's exciting that it could help us answer this huge question in paleontology," O'Connor said.