Ironically, he became a mycologist—an aficionado of fungi. And he eventually came to study the very mushrooms that he had once experienced, precisely because so few others had. “I realized how pitifully little we still knew about the genetics and ecology of such a historically significant substance,” he says.

Why, for example, do mushrooms make a hallucinogen at all? It’s certainly not for our benefit: These mushrooms have been around since long before people existed. So why did they evolve the ability to make psilocybin in the first place?

And why do such distantly related fungi make psilocybin? Around 200 species do so, but they aren’t nestled within the same part of the fungal family tree. Instead, they’re scattered around it, and each one has close relatives that aren’t hallucinogenic. “You have some little brown mushrooms, little white mushrooms ... you even have a lichen,” Slot says. “And you’re talking tens of millions of years of divergence between those groups.”

It’s possible that these mushrooms evolved the ability to make psilocybin independently. It could be that all mushrooms once did so, and most of them have lost that skill. But Slot thought that neither explanation was likely. Instead, he suspected that the genes for making psilocybin had jumped between different species.

These kinds of horizontal gene transfers, where genes shortcut the usual passage from parent to offspring and instead move directly between individuals, are rare in animals, but common among bacteria. They happen in fungi, too. In the last decade, Slot has found a couple of cases where different fungi have exchanged clusters of genes that allow the recipients to produce toxins and assimilate nutrients. Could a similar mobile cluster bestow the ability to make psilocybin?

To find out, Slot’s team first had to discover the genes responsible for making the drug. His postdoc Hannah Reynolds searched for genes that were present in various hallucinogenic mushrooms, but not in their closest non-trippy relatives. A cluster of five genes fit the bill, and they seem to produce all the enzymes necessary to make psilocybin from its chemical predecessors.

After mapping the presence of these five genes in the fungal family tree, Slot’s team confirmed that they most likely spread by jumping around as a unit. That’s why they’re in the same order relative to each other across the various hallucinogenic mushrooms.

These genes seem to have originated in fungi that specialize in breaking down decaying wood or animal dung. Both materials are rich in hungry insects that compete with fungi, either by eating them directly or by going after the same nutrients. So perhaps, Slot suggests, fungi first evolved psilocybin to drug these competitors.

His idea makes sense. Psilocybin affects us humans because it fits into receptor molecules that typically respond to serotonin—a brain-signaling chemical. Those receptors are ancient ones that insects also share, so it’s likely that psilocybin interferes with their nervous system, too. “We don’t have a way to know the subjective experience of an insect,” says Slot, and it’s hard to say if they trip. But one thing is clear from past experiments: Psilocybin reduces insect appetites.