The pine marten has emerged as an unlikely ally for the beleaguered native red squirrel in its battle with the grey squirrel.
This is according to scientists at the University of Aberdeen, who carried out an in-depth forensic study of the relationship between the three species.
The pine marten is a predator of the reds, but in areas where it thrives, the number of grey squirrels reduces.
The findings are published in Proceedings of the Royal Society B.
The journal study suggests that the pine martens reverse the "typical relationship" between red and grey squirrels, where the red always loses out, according to lead researcher Dr Emma Sheehy.
"Where pine marten activity is high, grey squirrel populations are actually heavily suppressed. And that gives the competitive advantage to red squirrels," she said.
"So you see lots of red squirrels and you see them coming back into areas where they hadn't been for quite some time."
To work this out, the team carried out what Dr Sheehy described as "forest CSI". She and her colleagues attached sticky pads to the undersides of baited feeder boxes.
"All three species use these boxes and when an animal lifts the lid with its head, it leaves us a little hair sample for our analysis," Dr Sheehy said.
With DNA from those hair samples and images from motion-activated cameras confirming which animals were visiting the feeders, the scientists were able to assess each species' population and activity levels.
Pine martens - cat-sized members of the weasel family - are gradually becoming re-established in parts of Scotland, after their near extinction in the UK.
They used to be trapped in large numbers by game-keepers, and also hunted for their fur, which was a valuable export from Scotland.
It is has been illegal to hunt the animals since the 1980s, and their numbers are now increasing. In recent years, evidence has emerged that they are also crossing the border and becoming established in Northumberland. A small population of the mammals was also relocated in 2015 from Scotland to Wales.
This evidence - that their comeback has given a boost to red squirrel survival - could indicate that they are able to catch and eat the non-native greys more easily.
"Red squirrels co-evolved with pine martens," explained Dr Sheehy. "They've managed to co-exist over such a long time and their population doesn't seem to be affected by losing the odd individual to a predator."
Grey squirrels on the other hand were introduced from the eastern coast of North America, where there are no pine martens.
"They aren't used to living with a predator so adept at climbing trees, and they spend a lot more time on the ground. So, theoretically, they are much more susceptible," Dr Sheehy told BBC News.
"We have the case of the recovery of one very rare protected species actually helping the recovery of another species, for which we didn't know what the future held.
"So it's kind of a two-in-one good news conservation story."
Co-author, Xavier Lambin, a professor of ecology at Aberdeen, commented: "Over time, this should lead to the near elimination of grey squirrels, though much uncertainty remains on the time required before this outcome materialises.
"Crucially, in relation to red squirrel conservation and the interests of the Red Squirrel Survival Trust (RSST), we find a strong positive association between red squirrel occupancy and pine marten density.
"This result is obviously very important and should alleviate the concerns expressed by some that the pine marten will depress red squirrel abundance after they have 'finished off' the grey squirrels."