By Andrew Osborn
MOSCOW (Reuters) - Russian President Vladimir Putin has brokered a Nagorno-Karabakh peace deal that locks in territorial gains for Turkey-backed Azerbaijan. In doing so, he has thwarted a stronger Turkish presence in a region Moscow views as its backyard.
Six weeks of heavy fighting between Azerbaijan and ethnic Armenian forces over the enclave have tested Moscow's influence in the South Caucasus, a swath of the former Soviet Union it views as vital to defending its own southern flank.
Three previous ceasefires, at least one of which was brokered by Moscow, fell apart. Azerbaijan accidentally shot down a Russian military helicopter, killing two. And Turkish President Tayyip Erdogan backed the Azeri offensive militarily and diplomatically and tried to gatecrash mediation efforts.
In the end though, Putin has achieved a more than two decades Russian dream of inserting Russian peacekeepers into Nagorno-Karabakh on a renewable five-year basis and, for now, kept Turkish troops, who will instead help run a ceasefire monitoring centre outside the enclave, out.
That expands Russia's military footprint, putting an apparent end to geopolitical competition between Moscow and Ankara of the kind that continues to play out in Syria and Libya.
With the wider deal, Putin has staved off a full Turkish-backed Azeri takeover of Nagorno-Karabakh however, which ethnic Armenians forces said was just days away from falling, and reaffirmed Russian influence in the region by brokering a deal which excluded Turkey as a signatory.
"Today's deal...in many ways addresses core Russian interests in the conflict, and is perhaps the best outcome (at least in short term) Moscow could get," said Alexander Gabuev, a senior fellow at the Carnegie Moscow Center think tank.
"Russia has put its 2,000 peacekeepers in Nagorno-Karabakh - something that Moscow wanted to do back in 1994, but was unable to. There will be no Turkish armed peacekeepers, which is very important for Moscow."
Ankara has said the ceasefire deal was a "sacred success" for its ally Azerbaijan while Erdogan, who has yet to comment, has described Ankara's support for Azerbaijan as part of Turkey's quest for its "deserved place in the world order".
Ozgur Unluhisarcikli, director of the German Marshall Fund research group in Ankara, said the Russian presence in the area was a negative for Turkey and Azerbaijan but the Azeri position was now far stronger than six weeks ago.
"Azerbaijan has obtained a great success in the field and this is consolidated by this ceasefire," he said.
Ankara did not need permission to send its forces to observe the ceasefire, Unluhisarcikli said, although it was unclear if Moscow had accepted that.
Eurasia Group said Erdogan would probably not be too upset by the way things had turned out.
"Turkey maintains some role, but it is clearly secondary to Russia’s," it said in a research note. "Erdogan is likely fine with this. His military support for Azerbaijan made a big difference at relatively little cost to Turkey, and it granted Ankara a nationalist win and some leverage with Russia."
That said, Russia's peacekeepers, armed and backed with armoured vehicles, freeze the conflict, making it impossible for Azerbaijan or Turkish-backed proxy forces to advance further.
There's another potential dividend for Moscow, which has a defence pact with Armenia and maintains a military base there.
Armenian Prime Minister Nikol Pashinyan swept to power on the back of 2018 street protests which forced the then government to resign.
Moscow has had an uneasy relationship with Pashinyan ever since, seeing him as less pro-Russian than his predecessors on key policy issues and as someone who unseated a generation of Kremlin loyalists.
The Karabakh deal, seen by many Armenians as a sell-out, puts Pashinyan under pressure, with opposition political parties calling for him to resign.
Angry crowds stormed government buildings overnight, including his official residence which was looted, and Pashinyan was forced to deny allegations he had fled the country.
Moscow would be unlikely to mourn his downfall if it happened.
But even as Moscow savoured its diplomatic coup, Mark Galeotti, a senior associate fellow at the Royal United Services Institute, said the ceasefire deal flattered to deceive.
"This is managing decline, a Russia that in regional terms is strong in capacities, weak in will, trying to make the best of a situation, and in the process disappointing its allies and doing nothing to deter its challengers," he wrote in a Moscow Times opinion piece.
(Editing by Jon Boyle)