It was 1996, Bill Clinton was president, and endangered bald eagles were dying in his home state of Arkansas.

Twenty-nine were found dead at a man-made reservoir called DeGray Lake, before deaths spread to two other lakes. But what really puzzled scientists was how the eagles acted before they died. The stately birds were suddenly flying straight into cliff faces. They hit trees. Their wings drooped. Even on solid ground, they stumbled around as if drunk.

“We weren’t in the political limelight that often,” says Carol Meteyer, who was then a pathologist for the National Wildlife Health Center, a usually obscure federal agency that investigates animal deaths. But as the toll rose, to more than 70 eagles in total, the mass die-off of America’s national bird in the president’s home state took on outsize symbolic importance. Scientists around the country were detailed to the case, but they kept coming up empty: It wasn’t botulism. It wasn’t heavy metals. It wasn’t pesticides. It didn’t seem to be anything known to man. “About the only thing that hasn’t been tested for is second-hand cigarette smoke,” an official told The New York Times in 1998. “We’ve even had people calling in suggesting that it’s radiation from outer space.”

Now, in an extraordinarily exhaustive new study, scientists have pinpointed the cause of death for those bald eagles in Arkansas. No wonder the mystery took 25 years to solve: The birds died because of a specific algae that lives on a specific invasive water plant and makes a novel toxin, but only in the presence of specific pollutants. Everything had to go right—or wrong, really—for the mass deaths to happen. This complex chain of events reflects just how much humans have altered the natural landscape and in how many ways; unraveling it took one scientist the better part of her career. “It’s just an amazing story,” says Gregory Boyer, a biochemist at the SUNY College of Environmental Science and Forestry, who was not involved with the study.

Susan Wilde, an aquatic scientist at the University of Georgia and a lead author on the new study, began looking into the mysterious deaths in 2001. By then, the cause of death had a name, at least—avian vacuolar myelinopathy, or AVM, which refers to empty spaces or vacuoles found in the brains of these dead birds. This brain damage is why the afflicted bald eagles seemed blind and uncoordinated.

Wilde had a few other clues to work with by 2001. Coots, which are water birds that live on the same lakes, were also becoming sick and uncoordinated. They would “be swimming upside down and struggling to keep their heads out of water,” says Meteyer, who investigated AVM for the National Wildlife Health Center. The coots were easy prey for eagles, who ate the sick birds—only to get sick in the same way. Whatever caused AVM was likely being passed through the food chain.

And what were coots eating? Water plants. Scientists had ultimately identified AVM in birds at 10 lakes in six southeastern states—all man-made and all being taken over by an invasive plant called Hydrilla verticillata. Wilde had written her doctoral dissertation about one of the lakes before it was invaded by hydrilla; she returned to find dense mats of the hardy plants. They could thrive in the man-made lake, whose waters were too nutrient-poor for native species. She saw spots on their leaves too, which she investigated under a fluorescent microscope. “The light shone down on the leaves and I said, Wow, the leaves are covered with this species I’ve never seen before,” Wilde told me. She recognized the spots as a new species of cyanobacteria, or blue-green algae, and she immediately thought they had to be important. This was 2001.

A series of experiments began to confirm her hunch. Ducks or chickens in the lab fed hydrilla without the cyanobacteria did just fine. Those fed hydrilla with the cyanobacteria got brain lesions like the eagles. Cyanobacteria do sometimes produce toxins that can kill fish and birds. But these toxic cyanobacteria typically float in the water, rather than live on plants, so this was unusual. “I can remember when Susan first identified that. There was a lot of skepticism,” Boyer says. “None of the known toxins were involved.”

Wilde and her colleagues knew they needed to identify the toxin itself. In 2011, she sent samples to Timo Niedermeyer, a biochemist now at the Martin Luther University of Halle-Wittenberg, in Germany, who specializes in molecules made by cyanobacteria. He and his colleagues tried to grow the species in his lab, but it grew incredibly slowly. It took two years to produce less than an ounce, which he sent back to Georgia to test in chickens. The cyanobacteria so painstakingly cultivated had no effect at all. No lesions. No clumsy behavior. “We spent two years and achieved nothing,” Niedermeyer says.

The team wondered if lab-cultivated cyanobacteria were somehow different from wild ones. But how? Niedermeyer went back to samples collected in the lakes, using a sophisticated technique called AP-MALDI-MSI—“like taking a picture but you don’t detect light but molecules,” he says—which revealed a novel molecule found only in the cyanobacteria growing on the hydrilla. The lab-grown cyanobacteria did not have it, nor did hydrilla by itself.

What’s more, this molecule had a formula never seen before, and, unusually, it contained five atoms of the element bromine. So the team tried adding bromine to its growing cyanobacteria. Lo and behold, the same strange molecule appeared, and this new batch of cyanobacteria caused the brain lesions in chickens. Another group of collaborators confirmed the team’s work further, by finding the cyanobacteria genes likely responsible for synthesizing the toxin. The team ultimately named this toxin aetokthonotoxin, “poison that kills the eagle.” Twenty-five years later, it finally had a name.

“I just have a lot of admiration that the scientists kept plugging away at this,” says Meteyer, the pathologist who helped identify AVM. Over the years, when asked about the frustrating parts of her career, she’s pointed to AVM as one of them.

Yet there are still more puzzles to solve. Where is the cyanobacteria getting the bromine? The element is relatively rare in fresh water, but Wilde says that hydrilla seems to sequester it. The concentration in the plant is 300 times higher than in the water column. How bromine is getting into the lakes in the first place is another mystery; the study authors suggest that it could be from coal plants that use bromine to remove mercury or, ironically, from herbicides used to kill the invasive hydrilla.

The key to preventing bird deaths from AVM might be simply weeding out hydrilla. The conditions that led to the original eagle deaths—a man-made lake, an invasive plant, bromine pollution—were an accidental confluence of many human choices that engineered the environment. Remaking the world for bald eagles means engineering their habitats again, but deliberately. One strategy, Wilde said, is stocking lakes with sterile grass carp, which are “shocked” with changes in temperature or pressure in the egg stage to give them an extra chromosome. These carp live several years and eat the hydrilla, but are unable to reproduce. (Lab studies on whether the toxin affects the fish have been contradictory.)

In Arkansas, where this all started, biologists stocked DeGray Lake with sterile grass carp, as well as a fly native to Pakistan whose larvae eat hydrilla. Those measures, along with a yearslong drought, wiped out the hydrilla completely. Bald eagles there are no longer afflicted by AVM. And bald eagles across the country are no longer endangered, thanks to decades of conservation efforts including the elimination of DDT. Scientists are now trying to restore the native vegetation at DeGray Lake, this time without hydrilla and its associated toxin-producing cyanobacteria.