Image copyright Menna Jones Image caption Fighting cancer with evolution: The Tasmanian devil

A genetic study of Tasmanian devils has uncovered signs that the animals are rapidly evolving to defend themselves against an infectious face cancer.

One of just three known transmissible cancers, this tumour has wiped out 80% of wild devils in the past 20 years.

Researchers looked at samples from 294 animals, in three different areas, before and after the disease arrived.

Two small sections of the devil genome appear to be changing very fast - and contain likely cancer-fighting genes.

The team, made up of US, UK and Australian scientists, described their findings in the journal Nature Communications.

They say the results offer much-needed hope that the species, which is unique to Tasmania, could survive the disease.

Devil facial tumour disease (DFTD) was discovered in 1996 and kills nearly every devil it infects. Essentially a single tumour that jumps between hosts, it is transferred when the aggressive beasts bite each other's snouts.

Only two other infectious cancers are known to science. A similar tumour is shared between the genitals of dogs when they mate, and has traversed the globe since it originated 11,000 years ago; another was discovered in 2015 affecting clams on the US west coast.

Image copyright Getty Images Image caption Devil facial tumour disease (DFTD) had looked likely to wipe the species off the map

Speaking to journalists in a teleconference, co-author Dr Paul Hohenlohe said he and his colleagues were in a unique position to observe the Tasmanian devil population responding to the cancer threat - because their samples spanned separate locations and reached from 1999 through to 2014.

Using the latest DNA sequencing methods, they were able to look for changes right across the devil genome.

"We characterised about 800,000 locations across the genome of each individual Tasmanian devil," said Dr Hohenlohe, an evolutionary biologist at the University of Idaho.

"Our goal is to look for genetic variants that could convey some sort of resistance… so that it may be possible to manage captive populations to ensure that that genetic variation is maintained."

Sure enough, among that wealth of data, the team found that two particular stretches of DNA were under acute selection pressure: they were changing faster than the rest of the genome, and specific gene variations were obviously on the rise - in all three populations.

Image copyright Thinkstock Image caption The species is the largest living marsupial carnivore

Most importantly there were seven particular genes, within those favoured regions, that looked like good anti-cancer candidates. They were connected to the activity of the immune system, for example, or there was a matching gene in humans with a known link to cancer.

"Particularly, there are several that seem to be involved in directing immune cells to dysfunctional cells or pathogens, and we think those are particularly promising," said Dr Brendan Epstein from Washington State University, the paper's first author.

His colleague Dr Andrew Storfer, also from Washington State, said this was cause for optimism. Despite the devils' steep decline, several populations - including those in the study - have survived beyond the point where scientists expected them to vanish.

These findings may explain why.

"First and foremost, this gives us hope for the survival of the Tasmanian devil, which is predicted to be extinct but isn't," Dr Storfer said. "We see that the devils apparently are evolving genes that may be associated with resistance to the disease."

Particularly exciting, he said, was the speed at which these adaptations appeared to be happening.

"We're talking about roughly six generations in some populations, which is a very short period of evolutionary time."

Image copyright Getty Images Image caption Tasmanian devils transmit the cancer when they bite each other

The team is now working to characterise the specific genes in more detail. There may be things to learn that could help tackle cancer in humans - or explain where these baffling contagious cancers came from.

"One of the big questions is, what do these cancers have in common? [Then] we can figure out how cancers evolved to be transmissible in the first place," Dr Storfer said.

The tumour spreading between bivalves in the Pacific can actually jump from one species to another, he added.

"The fear is that we may see more cancers down the road that are transmissible between species."

Dr David Rollinson is a biologist at the Natural History Museum in London who specialises in the genetics of how hosts and parasites evolve together.

He said the new study was an impressive - and encouraging - example of natural selection in action.

"I find it quite exciting," Dr Rollinson told the BBC. "There's been great concern that the Tasmanian devils may be wiped out by this strange, transmissible cancer.

"And it now seems that there's just a little bit of hope - that the selection pressure is actually driving a response by the devils, so they're getting a genetic profile that might actually give them some protection."

Follow Jonathan on Twitter