Caterpillars that eat tobacco plants protect themselves by pumping out a nicotine-laced substance, a new study says.

Findings published in the latest Proceedings of the National Academy of Sciences show the caterpillars in question retain nicotine toxin in their blood, which allows them to blow a noxious warning to would-be predators.

"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. It also proof that studying animals in a natural habitat rather than just in the lab is extremely important to understanding what really happens in their world, he added.

Baldwin and his colleagues found a gene in hornworm caterpillars that allows them to puff nicotine out through tiny holes in their sides as a warning to those who would hunt them, mainly wolf spiders.

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

Nicotine is a natural toxin that can prove deadly for humans, as well as other creatures.

In one case, two brothers died after smoking 17-18 pipes full of tobacco. Health problems can also result if a person touches wet tobacco leaves, since Nicotine can be absorbed into the body, causing a a variety of negative reactions.

The caterpillars apparently have a gene that allows them to divert nicotine into external respiratory openings, through which they then release the toxic puffs.

Insects have long used plant toxins as protect, as evidenced by a caterpillar with toxic barf.

"The eastern tent caterpillar -- Malacosoma americanum -- regurgitates hydrogen cyanide and benzaldehyde ingested from their cyanogenic host plants when attacked by ants," explained researcher Pavan Kumar to reporters.

The Atala butterfly, otherwise known as the Eumaeus atala, also acquires a toxic plant substance that wards off birds and ants. And rattlebox moths ingest alkaloids poisonous to spiders -- which, as a result, avoid the moths.

So, the tobacco hornworm caterpillar keeps at bay wolf spiders, which usually consider the caterpillars to be good to munch on.

The scientists used genetic engineering to create tobacco plants that would not activate the specific defensive gene in the caterpillars, even after the critters ingested nicotine. The wolf spiders, therefore, had no reason to stay away and ended up eating well that day.

The research might enable scientists to make bugs more appealing to predators or creating genetically engineered plants better able to withstand insect infestations.