By now, everyone’s seen that chilling Planet Earth clip where a helpless ant marches, against its own will, up a branch that will become its grave. In an epic time-lapse, the ant pauses, lowers its head, and from its motionless skull suddenly sprouts the spear of the Cordyceps fungus, like a sword through dying flesh. The fungus is brutal. And, as scientists reveal in an Evolution study on Tuesday, it’s pretty sneaky as well.

The study, led by Penn State associate professor of entomology and biology David P. Hughes, Ph.D., shows that the Ophiocordyceps unilateralis fungus, one of many “neuro-parasites” that have evolved a way to physically manipulate its hosts, has evolved to ensure peak zombie-making ability in all environments, regardless of the climate. This discovery hinged on the previous observation that infected ants must always chomp down on a part of the plant or tree before the fungus can spew forth its deadly spores.

What Hughes and his colleagues discovered is that the part of the plant the ants bites depends the climate of the region, suggesting that the manipulative fungus has evolved, rather cleverly, to deal with its changing environment. “In tropical areas, zombie ants bite onto leaves, but in temperate areas, they bite twigs or bark,” Hughes said in a statement for Penn State on Tuesday.

zombie ants biting fungus
Infected ants in temperate forests bite down on branches, not unwieldy leaves.

This is a testament to how scary-good evolution can be at ensuring a species’ survival. We already know that the fungus first makes an ant chomp down on something because it’s easier to use a host body as a spore launching pad when it’s immobilized. Since the goal of the fungus is to be anchored to a point that ensures spore distribution (and thus reproduction), there are two criteria for a good chomping-down spot: It’s got to be high off the ground, and it’s got to be immovable. There’s no sense building your headquarters on shaky ground.

This is why, as Hughes and colleagues explain in the paper, it’s fine for an infected ant to bite a leaf in a tropical zone. In warm regions, leaves don’t fall off trees, and so O. unilateralis can rest easy knowing that its host won’t suddenly fall to the ground, where it’s useless. But in any part of the world where trees shed their leaves, it’s crucial that the ant anchors itself to something more permanent, like a twig. By analyzing images of zombie ant corpses from collections around the world, the team found that infected ants in tropical zones indeed attached themselves to leaves, whereas those in temperate forests not only chomped down on twigs but, in 90 percent of cases, wrapped its legs around the twig, just to ensure it wouldn’t fall off.

zombie ants
There's a different Cordyceps species for every type of ant, but they all work in the same way: Drop anchor and spew spores.

Through an evolutionary analysis, the authors show that the fungus’s default strategy is to make its hosts bite down on leaves so that the twig-biting variant evolved independently twice over the course of its evolution. The changes likely happened about 40 to 20 million years ago, they write, likely because the fungus was carried from tropical forests to more temperate regions in North America and Japan.

“The data presented here provide multiple lines of evidence suggesting a parasitic fungus inside ant hosts can respond to environmental change and alter the way it manipulates its host behavior over evolutionary time,” the team writes. There’s no telling how the fungus will adapt as human-induced climate change continues to mess with plant biology, but if its persistence over the past several epochs is any indication, Cordyceps will find a way to stay in control.