Of all the interesting insects on our planet — and we have about 1.7 million known species to choose from — the bombardier beetle may be the most interesting. It deters would-be attackers, such as ants, frogs and lizards, by shooting hot, toxic chemicals from its body.

And it does it “without killing or even burning itself; it’s amazing,” says Athula Attygalle.

Attygalle wanted to figure out how they do this. He’s an analytical chemist at Stevens Institute of Technology in Hoboken, New Jersey. Attygalle teamed up with other researchers, including Kipling Will, a biologist at the University of California at Berkeley.

Will collected 18 of the beetles. He fed and injected them with chemicals similar to the ones the beetles use to protect themselves. The chemicals are strong enough to irritate human skin and kill ants, but they didn’t bother the beetles at all.

Attygalle analyzed the beetles’ spray using a piece of equipment called a mass spectrometer.

The scientists were able to trace the route the chemicals take through the beetles’ bodies. The chemicals collect in a reservoir, where they are stored until they are needed.

That happens when the beetles are threatened — when they’ve been swallowed by a frog, for example. Valves open and the chemicals are pushed into a “reaction chamber.” There, they are mixed with enzymes. This heats them to a boiling 212 degrees Fahrenheit (100 degrees Celsius). It also converts the chemicals into their final, sometimes-deadly product.

Then, “like detonating a bomb,” Attygalle says, the beetles shoot the spray from their backsides. The spray is so pungent and irritating, the frog spits the beetle out.

The scientists also discovered that how the spray is made is different than researchers once believed. Once it was thought that the two compounds in the spray were made from the same starting material. Scientists now say they’re made from two substances.

Attygalle says bombardier beetles aren’t the only ones that use these chemicals to protect themselves. Other beetles, spiders and some millipedes do, too. But bombardier beetles are the only ones that “heat it up and spray it,” Attygalle says. His team’s research shows that these different organisms “have independently come up with these mechanisms, which is biologically interesting.”

Many kinds of chemicals are important throughout the insect population. In fact, “nearly all insects are chemistry-controlled,” Attygalle says. “It’s why they have been so successful at surviving evolutionary pressures.”

For example, when monarch butterflies mate, the males transfer a toxic chemical to the females. This chemical protects their eggs from being eaten by predators.

Attygalle says his favorite part of insect-chemical research is having his theories proved right.

He and collaborators such as Will “start with stories, which need a lot of imagination — and often your imagination is wrong,” he says. “You wouldn’t believe how many times we get negative results.” But when it all pans out after months of trying, “all the bells are ringing — it worked! That is the biggest fascination and joy.”