Recently, a team of researchers noticed something odd about ants. Every time the insects swallowed food or water they would start cleaning the glands on their butt ends.

"The behaviour didn't seem to be linked to digestion, because ants do this even after they have only ingested water," said zoologist Simon Tragust from the Martin Luther University in Germany.

So Tragust and colleagues decided to see what happened if they prevented the ants from being able to reach their own butts. They allowed Florida carpenter ants (Camponotus floridanus) to feed first, and then immobilised them with ice (when ants get too cold they stop moving, but are fine again once they heat up) and tested their digestive system pH levels.

The ants acid levels dropped when ants were unable to suck up the poisonous substance called formic acid that oozes from a gland called an acidopore on their abdomens.

Carpenter ants use formic acid to disable prey, smearing it in after biting their poor victim with their powerful mandibles. But formic acid is best known for how ants use it as a weapon against predators, with some species, like wood ants, capable of hurling this poison at their enemies' faces.

Some birds take advantage of this behaviour by getting the ants to spray them with it, thus ridding themselves of pests. We humans also use formic acid as an antibacterial agent in livestock feed, in pesticides, for wart removal, and have even found a role for it in potential future energy technologies.

It seems that ants, like us, have been using it for multiple purposes too, including as a chemical disinfectant. They use formic acid to keep their nests hygienic and clean their babies with it - keeping the spread of harmful fungi in check. The new study shows they also use this acid to keep their innards parasite free.

"We found that access to the poison improved survival of formicine ants after feeding on pathogen contaminated food," the team wrote in their paper.

When humans wallop a high dose of formic acid it causes corrosive burns to our tissues, headaches and confusion if inhaled; when ingested, it can lead to bloody vomiting.

But ants are clearly made of tougher stuff.

They also have an unusually low level of microbial diversity in their gut microbiome. This is particularly strange, given how they share food with each other, spend a lot of time together (which we're all now far too keenly aware of is an ideal way to spread pathogens) while enclosed in tunnels of dirt or rotting wood (ideal homes for all sorts of microorganisms). Lacing their own digestive system with formic acid could explain it.

But the acid still allowed one group of bacteria to survive, Acetobacteraceae. In lab tests the researchers showed these bacteria could withstand and thrive while incubated in a medium containing formic acid, whereas the known pathogenic microbe species they tested did not.

The team explains this bacterium is found in many ant species and recent studies suggest it might be useful to the ants, possibly in helping them digest required nutrients.

"Acid swallowing acts as a filter mechanism, structuring the ant's microbiome," said Tragust.

While highly acidic stomachs are common in animals with backbones like us, it's only rarely been seen in insects; how they maintain this low pH level is unknown. But sanitising food through antimicrobial methods is particularly prevalent in animals that provide food for their young, as ants do.

Tragust and team found ants without access to their butt poison had variable acidity in their crop - an area near the stomach that holds the food to share with the colony - which could suggest they have other ways of topping up the acid in their digestive system.

Perhaps it's internal, like how our stomachs secrete acids, but further studies are required to figure this out.

"The results of our study show that formicine ants maintain a highly acidic baseline pH in their stomach, the crop, through swallowing of their poison gland secretion during acidopore grooming," Tragust and team concluded.

This research was published in eLife.