For fans of a velvety latte or a jolting espresso, meet your greatest enemy: the coffee berry borer beetle. This tiny pest, just a few millimetres long, can ruin entire coffee harvests. It affects more than 20 million farming families, and causes losses to the tune of half a billion US dollars every year- losses that are set to increase as the world warms.

But the beetle isn’t acting alone. It has a secret weapon, stolen from an unwitting accomplice.

Ricardo Acuña has found that the beetle’s ancestors pilfered a gene from bacteria, most likely the ones that live in its gut. This gene, now on permanent loan, allows the insect to digest the complex carbohydrates found in coffee berries. It may well have been the key to the beetle’s global success.

But even when scientists find such case studies, they can rarely ascribe a specific function to the traded genes. These species may be exchanging DNA, but to what end? In a few rare cases, we have answers. Wasps use genes stolen from ancient viruses to make biological weapons. In another, fungal genes affect the colours of insects. And in the best known example of all, genes transferred from one microbe to another cemented the most important alliance in the history of life. Acuña adds to this exclusive list. In his study, the gene that jumped from bacterium to beetle has a clear purpose in its new body.

The beetle lays its eggs inside coffee berries, and its larvae eat nothing else. The berries are 60 per cent carbohydrates and to survive on them, the larvae need to digest these compounds effectively. To understand how it manages, Acuña catalogued the various genes that are switched on in the beetle’s gut.

One of them – HhMAN1 – stood out for two reasons. First, it creates a protein called mannanase that breaks down galactomannan, one of the major carbohydrates in copy beans. Second, insects aren’t meant to have mannanases.

Indeed, Acuña found that the borer’s gene was more closely related to similar genes in bacteria than to counterparts in plants, fungi or animals. He’s sure that the HhMAN1 gene comes from the beetle’s own genome, rather than from its gut bacteria, for its immediate neighbours are typical insect genes rather than bacterial ones.

In fact, these neighbours are transposons –genes that can cut themselves out of their host genome and paste themselves in elsewhere. These jumping genes might have smuggled the bacterial gene into the beetle’s DNA in the first place.

Once there, the gene would have provided the beetle with an important advantage. Coffee berry borers from across the world, from Asia to Latin America, all have the HhMAN1 gene, while other closely related beetles do not. This suggests that the gene found its way into the beetle’s genome before it became a worldwide scourge of coffee. Acuña thinks that the gene enabled the beetle’s world tour. It allowed the insect to digest the most common carbohydrate in its host of choice, to become the bane of coffee-farmers and coffee-lovers everywhere.

Vega et al. (Ann. Entomol. Soc. Amer. 95:374, 2002) reported the maternal inheritance of Wolbachia by beetle offspring. They detected Wolbachia in coffee beetles from Africa and the Americas. They thought this bacterium played a role in sex determination. Could it be that these bacteria also conferred a nutritional advantage?