Ripped from the pages of Lewis Carroll's "Alice in Wonderland," scientists have discovered a smoking caterpillar of sorts.

While this find may not push Alice's hookah-smoking insect from its psychedelic pedestal, this caterpillar is pretty snazzy, as it can use nicotine to ward off hungry wolf spiders.

The researchers found a gene in hornworm caterpillars that allows them to puff nicotine out through their spiracles (tiny holes in their sides), from the tobacco they consume, as a warning to their would-be predators. Researchers called this tactic "defensive halitosis." [Video – See the Smoking Caterpillars in Action]

"It's really a story about how an insect that eats a plant co-opts the plant for its own defense," said study researcher Ian Baldwin, a professor at the Max Planck Institute for Chemical Ecology in Germany.

But, said Baldwin, it's also an example of the importance of studying animals in a natural habitat rather than just in the lab.

"We never would have discovered the function of this gene if the spider hadn't told us," he told LiveScience.

The researchers discovered the odd halitosis when trying to find out how hornworm caterpillars could consume tobacco plants despite the toxic nicotine within the plant's tissues. In fact, these caterpillars are hundreds of times more resistant than humans who smoke are to the toxic effects of nicotine.

By feeding hornworm caterpillars tobacco plants with and without nicotine, researchers identified the gene that was activated when the caterpillars consumed nicotine-containing tobacco plants. The scientists then placed so-called interference RNA matching that gene in tobacco plants grown in the lab. The interference RNA targeted that gene, preventing the caterpillars from using their defense.

When caterpillars consumed the gene-altered tobacco, they lost their ability to produce the tobacco halitosis and thus their ability to ward off the spiders. As a result, they were consumed at a higher rate by wolf spiders, a rate similar to that found for caterpillars consuming nicotine-depleted tobacco plants.

This RNA-interference technique might someday be used in genetically modified crops produced with specific nutritional goals in mind, as interference RNA targets a specific gene. Early trials of medications using a similar principle to treat a rare disease called transthyretin amyloidosis in humans were published earlier this year.

"A very intriguing aspect of this study is the really state-of-the-art methodology that was used to determine the fate of nicotine," said May Berenbaum, a professor and head of the department of entomology at the University of Illinois at Urbana-Champaign, who edited the study for the journal.

While the study involved wolf spiders, the nicotine halitosis does not necessarily turn away other predators. This defense, Berenbaum noted, has the advantage of warning a predator of a prey's toxicity without requiring the prey to lose a limb.

Scientists may also want to determine whether hornworm caterpillars have other defenses against predators. For instance, the caterpillars also consume plants, such as tomatoes, which contain alkaloids that are not volatile like nicotine is. If a compound is not volatile, it isn't easily vaporized and so couldn't be emitted from tiny pores.

The study was published on Dec. 30 in the Proceedings of the National Academy of Sciences.