The deepest reaches of the Brazilian jungle harbour some of the most dangerous life on Earth, but the ants in the rainforest face an enemy more sinister than most.

On a recent field trip to the region, scientists discovered four new species of fungus that infect ants, take over their bodies and eventually kill them in a place that is just right for the organism to grow inside them.

The fungus can destroy entire colonies and leave behind gruseome ant graveyards, where twisted, dark corpses rest with their mandibles locked around leaf veins, a final act that secures the creature's host in position before it releases spores to infect others.

David Hughes at Penn State University and Harry Evans at CABI in Surrey identified the four species of Ophiocordyceps fungus while working in the Atlantic rainforest in Minas Gerais, southeastern Brazil.

"It's a fabulously complex organism," Hughes told the Guardian. "There is a beauty to the whole thing, whether it is the chemicals at work that take over the ant, or the spores which try one strategy and then another to find a host on the forest floor."

Records of "zombie-ant fungus" were made in 1859 by Alfred Russel Wallace, the great naturalist and contemporary of Darwin, who found two specimens in Sulawesi in Indonesia. Wallace also collected specimens in the Amazon to bring back to London, but he lost all of his material when his ship, Helen, caught fire and sank on the way home.

The most important modern specimen of an ant gripped by the fungus was stored at a museum in Paris, but was apparently lost after being loaned to a Japanese researcher in 1941.

Writing in the journal Plos One, the researchers describe the four species of fungus, each of which targets a different variety of Carpenter ant.

The lifecycle of the organism is extraordinary. Ants become infected with the fungus when spores land on them from above, or when they encounter them on the forest floor. Once attached, the spores use enzymes to get inside the ant's body where the fungus begins to grow. Within a week or so, chemicals released by the fungus cause the ant to wander off and bite on to leaf veins and other vegetation, moments before dying. Many ants are found in places where the conditions are perfect for fungal growth.

Once the ant has died, the fungus slowly sprouts from its head and grows a pod of spores which are fired onto the forest floor at night, to infect other ants.

The latest study reveals that some of the fungi produce spores that have a back-up plan if they fail to infect an ant within a day of being released. Spores that rest on the ground slowly grow a secondary spore, that juts upright from the forest floor, where it can latch on to ants as they pass.

The scientists have found six more species of the fungus in Cairns, Australia, home to some of the oldest rainforests on Earth.

• This article was amended on 3 March 2011. The original stated that the new species were discovered in the Amazon. This has been corrected.