When humans began farming crops thousands of years ago, agriculture had already been around for millions of years. In fact, several animal lineages have been growing their own food since long before humans evolved as a species.

According to a new study, colonies of ants began farming fungi when an asteroid struck Earth 66 million years ago. This impact caused a global mass extinction but also created ideal conditions for fungi to thrive. Innovative ants began cultivating the fungi, creating an evolutionary partnership that became even more tightly intertwined 27 million years ago and continues to this day.

In a paper published today, Oct. 3, in the journal Science, scientists at the Smithsonian’s National Museum of Natural History analyzed genetic data from hundreds of species of fungi and ants to craft detailed evolutionary trees. Comparing these trees allowed the researchers to create an evolutionary timeline of ant agriculture and pinpoint when ants first began cultivating fungi.

“Ants have been practicing agriculture and fungus farming for much longer than humans have existed,” said entomologist Ted Schultz, the museum’s curator of ants and the lead author of the new paper. “We could probably learn something from the agricultural success of these ants over the past 66 million years.”

Nearly 250 different species of ants in the Americas and Caribbean farm fungi. Researchers organize these ants into four agricultural systems based on their cultivation strategies. Leafcutter ants are among those that practice the most advanced strategy, known as higher agriculture. These ants harvest bits of fresh vegetation to provide sustenance for their fungi, which in turn grow food for the ants called gongylidia. This food helps fuel complex colonies of leaf cutter ants that can number in the millions.

Schultz has spent 35 years studying the evolutionary relationship between ants and fungi. He has conducted more than 30 expeditions to locales in Central and South America to observe this interaction in the wild and has reared colonies of leafcutter and other fungus-farming ants in his lab at the museum. Over the years, Schultz and colleagues have collected thousands of genetic samples of ants and fungi from throughout the tropics.

This stockpile of samples was crucial to the new paper.

“To really detect patterns and reconstruct how this association has evolved through time, you need lots of samples of ants and their fungal cultivars,” Schultz said.

The team used the samples to sequence genetic data for 475 different species of fungi (288 of which are cultivated by ants) and 276 different species of ants (208 of which cultivate fungi) — the largest genetic dataset of fungus-farming ants ever assembled. This allowed the researchers to create evolutionary trees of the two groups. Comparing wild fungal species with their cultivated relatives helped the researchers determine when ants began utilizing certain fungi.

The data revealed that ants and fungi have been intertwined for 66 million years. This is around the time when an asteroid struck Earth at the end of the Cretaceous period. This cataclysmic collision filled the atmosphere with dust and debris, which blocked out the sun and prevented photosynthesis for years. The resulting mass extinction wiped out roughly half of all plant species on Earth at the time.

However, this catastrophe was a boon for fungi. These organisms proliferated as they consumed the plentiful dead plant material littering the ground.

“Extinction events can be huge disasters for most organisms, but it can actually be positive for others,” Schultz said. “At the end of Cretaceous, dinosaurs did not do very well, but fungi experienced a heyday.”

Many of the fungi that proliferated during this period likely feasted on decaying leaf litter, which brought them in close contact with ants. These insects harnessed the plentiful fungi for food and continued to rely on the hardy fungi as life rebounded from the extinction event.

The new work also revealed that it took nearly another 40 million years for ants to then develop higher agriculture. The researchers were able to trace the origin of this advanced practice back to around 27 million years ago. At this time, a rapidly cooling climate transformed environments around the globe. In South America, drier habitats like woody savannas and grasslands fractured large swaths of wet, tropical forests. When ants took fungi out of the wet forests and into drier areas, they isolated the fungi from their wild ancestral populations. The isolated fungi became completely reliant on ants to survive in the arid conditions, setting the course for the higher agriculture system practiced by leafcutter ants today.

“The ants domesticated these fungi in the same way that humans domesticated crops,” Schultz said. “What’s extraordinary is now we can date when the higher ants originally cultivated the higher fungi.”

In addition to Schultz, the new paper included contributions from several coauthors affiliated with the National Museum of Natural History, including Jeffrey Sosa-Calvo, Matthew Kweskin, Michael Lloyd, Ana Ješovnik and Scott E. Solomon. The study also includes authors affiliated with the University of Utah; the Royal Botanic Gardens, Kew; the University of California at Berkeley; the U.S. Department of Agriculture; São Paulo State University; the Instituto de Investigaciones Científicas y Servicios de Alta Tecnología; the Smithsonian Tropical Research Institute; the University of Copenhagen; Emory University; McMaster University; Universidade Federal de Uberlândia; Arizona State University; the University of Hohenheim; and Louisiana State University.

The research was supported by the U.S. National Science Foundation; the Smithsonian; the University of Maryland; Louisiana State Board of Regents; Sistema Nacional de Investigación; Cosmos Club Foundation; Explorer’s Club in Washington, D.C.; São Paulo Research Foundation; Brazilian Council of Research and Scientific Development; Brazilian Federal Agency for Support and Evaluation of Graduate Education; the Royal Botanic Gardens, Kew; and the Carl Zeiss Foundation.