Hurbert Walter Simmonds had only been in Fiji for a year before he was appointed as Government Entomologist in 1920. It was an unusual role, but an important one. The island was repeatedly threatened by agricultural pests, and so Simmonds would spend the next 46 years searching for predators and parasites that could bring these crop-destroyers to heel.

In his downtime, he collected butterflies. There are thousands of species in Fiji, and the blue moon butterfly (Hypolimnas bolina) is among the most beautiful of them. The name comes from the males, whose black wings have three pairs of bright white spots, encircled by blue iridescence. They are stunning, and all males look the same. The females are more varied: they are clothed in a wide range of spots, stripes and hues, many of which mimic other local butterflies. Simmonds wanted to know how these patterns are inherited, so he started capturing and breeding the insects.

That’s when he noticed that most of the females only gave birth to females.

Some 90 percent of them would produce all-female broods. They laid large clutches of eggs and around half the embryos died—presumably, the male ones. Simmonds didn’t know why.

Meanwhile, 700 miles away on Samoa, British entomologist George Henry Evans Hopkins had found the same pattern in the same butterfly. The males were practically endangered: there was just one of them for every hundred females. In a book published in 1927, Evans wrote: “the rarity of the male is so marked as to lead inevitably to a suspicion that parthenogenesis must occur in this race.” In other words, the females were cloning themselves.

It was a decent guess for the time, but it was also wrong. When Greg Hurst, an evolutionary biologist from the University of Liverpool, stumbled across these records in the 1990s, he knew exactly what was behind the heavy skew towards females. “It was clearly a male-killing bacterium,” he says.

In the 80 years since Simmonds and Hopkins first studied the blue moon, scientists had discovered several species of bacteria that have a special antagonism towards males. They mostly live in the cells of insects and other arthropods, and they pass from one generation to the next by stowing away in eggs. Sperm, however, are too small to house them, so if they end up in a male, they are stuck. Females are their ticket to the future; males are an evolutionary dead end. So these microbes have evolved ways of favoring female hosts at the expense of male ones.

Some do it by killing male embryos in their eggs, before they are even born. This is a suicidal act, since the male-killers go down with their hosts. But their genetically identical clones live on inside the female embryos, which now face less competition. They might even get a nutritious boost—in insects like ladybirds, surviving siblings will cannibalize the remains of their dead brothers, giving them a valuable boost of nutrition early in life.

These male-killers are not rarities. They plague many different groups of insects, including flies, beetles, bugs, wasps, mosquitoes and more. Wherever they exist, males become rare and sex ratios skew away from the neat 1:1 equity that we see in ourselves and most other animals.

Hurst had seen these effects first-hand. He had already spent years studying male-killers in ladybirds and African butterflies. In the latter, the females outnumber males by 25 to 1. “That’s a silly sex ratio,” he says. The blue moon butterfly was even more ludicrous. When Hurst heard about it, he thought, “A 100:1 sex ratio was too good to miss.”

In 1999, he travelled to Fiji with graduate student Emily Dyson to see the butterflies for himself. Once they arrived, they quickly saw signs of the same sex bias that Simmonds described. Male butterflies normally defend the plants in their territories, so you will typically see many more males than females when you walk along a flowery path. But on these islands, Dyson and Hurst could go for weeks without spotting a male blue moon.

Dyson collected and bred the butterflies and sure enough, around 60 percent of the broods were all-female—a lower proportion than in Simmonds’ day, but still significant. The team discovered that the culprit was a well-known male-killing bacterium called Wolbachia. It was there in the ovaries of every butterfly from an all-female brood; the team detected traces of its genes, and could see it down a microscope.

Dyson continued working in Fiji for a year, until she was interrupted by an inconvenient military coup. “They’re very peaceful, but health and safety rules don’t allow you to leave your graduate student in the same place as a military coup,” says Hurst. “So she flew to Samoa.” There, she found the same extremely skewed sex ratio that Hopkins described eight decades earlier—100 females (mostly virgins) for every male (mostly tired). And there too, Wolbachia was responsible, and exactly the same strain as the one in Fiji.

Despite their lack of males, the blue moons were still clinging to existence, probably because Samoa is a laid-back ecosystem without many competitors or predators. Wolbachia, meanwhile, was living large. It had infected more than 99 percent of the available females, and achieved almost total dominance over the island’s blue moons. This single bacterium was the most important factor shaping the reproductive biology of the blue moon butterfly.

Wolbachia doesn’t just infect the blue moon; it’s also found in some 40 percent of species of insects and arthropods, as well as other animals like parasitic nematode worms. Scientists still disagree about whether the various lineages (or “supergroups”) should be classified as a single species or as many separate ones. But however you cut it, Wolbachia is everywhere.

As I’ve written in The Atlantic before, many scientists are trying to use this omnipresent microbe to stop important tropical diseases like dengue fever, Zika, and elephantiasis. Others, like Hurst, are studying it for its own sake, including the extraordinary ways in which it manipulates its hosts. Sometimes, as in the blue moon butterfly, it kills males outright. In other hosts, it can transform males into females, or even turn females into cloners that can reproduce asexually without needing males at all.

These strategies don’t go unanswered. A drought of males is hardly conducive to a species’ survival, so many insects evolve ways of resisting this misandrist microbe. The blue moon butterfly is one of them.

In 2005, Hurst got an email from his colleague Sylvain Charlat, who was traveling through the Pacific and checking in on the blue moon. On Savaii, one of the Samoan islands, Charlat found no males, as expected. But on Upolu Island, a mere 10 mile swim away, there were males aplenty. The team returned in 2006 for a formal census.

By then, the sex ratio on Upolu was completely equal, and whatever was causing it had spread to Savaii. On the far side of the island, the males were still in the minority but on the near side, they equalled the females in number. In barely ten generations, they had gone from virtual non-existence to equality. That was, and still is, one of the fastest evolutionary changes ever observed—almost a century of stagnancy, and then one year of extreme change. The team were extraordinarily lucky to have been there, watching, at exactly the right time.

Wolbachia hadn’t disappeared. It was just being suppressed by a mystery gene that the team are still trying to pin down. At some point, a male butterfly carrying this suppressor gene arrived in Samoa, probably from a neighboring island. It mated with the local females, who gave birth to sons that also carried the suppressor. Before long, the gene was everywhere.

Emily Hornett, another of Hurst’s students, showed that these battles play out all over the Indo-Pacific. Wherever the blue moon butterfly exists, it does battle with male-killing bacteria. It’s losing in some places, and winning in others, resulting in sex ratios that vary wildly in both space and time.

But even when the butterfly wins, Wolbachia doesn’t really lose. Normally, if a host evolves to resist a parasite, the parasite’s numbers should fall. But in the resistant blue moon butterflies of Upolu and Savaii, Wolbachia didn’t yield any ground. It wasn’t killing males any more, but it was as common as ever.

That’s because it has another one final strategy for manipulating its hosts. If Wolbachia allows males to survive, it often changes their sperm so that they cannot successfully fertilize an egg, unless that egg is infected with the same strain of Wolbachia. This means that infected females, who can mate with whomever they like, get a competitive advantage over uninfected females, who are restricted to uninfected males. With each passing generation, they make up a greater slice of the population, and the Wolbachia they carry spread with them. This trick is called cytoplasmic incompatibility, and it is Wolbachia’s most common one.

Hornett discovered that the strain from Fiji and Samoa always had this skill as part of its repertoire, but never had the chance to use it because it kept on killing off all the males. When the suppressor gene spread through the blue moon butterflies, males survived, and Wolbachia could manipulate them too.

So, rather than driving it out, the suppressor gene actually cemented Wolbachia’s presence in the islands. Even in defeat, this most common of symbionts was victorious.