A new study reveals that one species of ant can amputate the legs of another species and can also determine whether it is necessary based on the location of the injury.

Ants are territorial and can find themselves clashing with rival colonies, which can lead to injuries, scientists say. But Florida carpenter ants, also known as Camponotus floridanus, have adopted an effective treatment for injuries: amputation, according to the study published in Current Biology.

The amputation process takes about 40 minutes and requires an ant to gnaw off the affected leg of its nestmate, according to Laurent Keller, one of the study’s researchers.

“They go into the top part (of the ant’s leg) and the mandible will cut it off,” Keller told ABC News. “The other ant will clean out the new wound.”

After one researcher reported his amputation observation to other researchers in a lab in Switzerland, they noticed that carpenter ants were selectively performing amputations.

PHOTO: Florida carpenter ants are among the largest ants found in Florida. (Abode)

If an injury was near the femur rather than the tibia, the ants would amputate. The researchers looked at the decision-making process behind amputation and performed micro-CT scans on the amputated ants, according to the study.

The researchers hypothesized that the closer the injured muscle was to the body, the more likely it was that surgery would take place.

“We had the hypothesis that perhaps the level of injury on a tibia had an infection that had progressed too quickly for the ants to cut off the leg to avoid infection,” Keller said.

MORE: After the eclipse: Nature’s next big show: the double emergence of cicadas

According to the study, the ant’s femur is primarily responsible for circulating hemolymph in the legs, similar to human blood flow, and so cutting it slows the rate at which an infection spreads and allows enough time to perform an amputation.

The ants with shin injuries were not left to die. Instead, they received treatment for their injuries, the researchers said. Keller noted that no research has been done on how an ant cleans a wound.

PHOTO: Florida carpenter ants work on the bark of a palm tree. (Adobe)

“We haven’t studied how they actually do it, but we think the mandible must be very clean when they do it,” Keller said.

The study published in Current Biology builds on previous research showing that termite-hunting ants have metapleural glands that allow them to produce an antimicrobial compound to treat affected wounds. However, carpenter ants, among other communities, have lost this ability due to evolution.

MORE: Ants turn carnivorous when salt is scarce, study finds

Keller said future research will involve looking at other ant communities that have lost their metapleural glands and finding common ancestors to assess when and how the behavior evolved.

While humans have been performing medical amputations for more than 30,000 years, this study reports the first observation of how a non-human species is able to perform targeted surgery.

“We have a cultural transmission of what has been learned and for ants it is a behavior that has evolved on an innate basis,” Keller said.

These ants can perform leg amputations and know when it’s necessary, according to a study originally published on abcnews.go.com