The lore that shrouds Australia’s giant stinging trees, of the genus Dendrocnide, is perhaps as dubious as it is vast. Tales abound of nightmarish encounters with the hypodermic-needle-like hairs of its leaves injecting a toxin that drives men to madness and has prompted horses to hurl themselves off cliffs.

Some of these stories are centuries old and cannot be verified. But as Edward Gilding can attest, these legends contain at least one lick of truth: the agony of being stabbed by the downy hairs that adorn the leaves and stems of Dendrocnide. The trees, which can grow taller than 100 feet, are found throughout the rainforests of eastern Australia.

“It’s like having a nail shoved into your flesh,” said Gilding, a biologist at the University of Queensland.

The sting also has staying power, doling out anguish in waves for hours or days. Some anecdotes have reported intermittent pain lasting months.

Now researchers have identified some of the ingredients involved. As they report in the journal Science Advances, Australia’s stinging trees are packed with a toxin that, when injected, latches on to pain-detecting cells and makes them go haywire, locking the afflicted area into the molecular equivalent of an infinite scream.

“So many things induce pain, and so little is known about why,” said Isaac Chiu, a neurobiologist at Harvard University. Chiu noted that the trees’ toxins target a molecule, found on nerve cells, that is “fundamental to mammalian pain,” he said. “If this reveals something that blocks that, it would be really exciting.”

The painful potency of Dendrocnide plants has bedeviled researchers for decades. But Irina Vetter, a pain researcher at the University of Queensland, Gilding and their colleagues were able to separate out the chemical components of the toxin from two Dendrocnide species and create synthetic versions. Dumped onto nerve cells, the molecule flipped the trigger-happy cells into an “on” position, forcing them to send out a deluge of signals.

Vetter was amazed to find that the pain-causing molecules bore a remarkable resemblance to toxins made by venomous spiders and cone snails.

“These are three widely divergent groups of organisms — spiders, cone snails and now these trees — producing a toxin that’s very similar,” said Shabnam Mohammadi, a toxin researcher.

It’s a stunning example, she added, of different branches of the tree of life converging on the same solution.