Hundreds of Russian peacekeepers were heading to Nagorno-Karabakh on Tuesday after Armenia and Azerbaijan agreed to a peace deal to end weeks of fierce fighting over the disputed region.
The Moscow-brokered agreement, which saw a ceasefire take effect at 2100 GMT came after a string of Azerbaijani victories in its fight to retake the ethnic Armenian enclave.
It sparked celebrations in Azerbaijan but fury in Armenia, where protesters took to the streets to denounce their leaders for losses in the territory, which broke from Azerbaijan's control during a war in the early 1990s.
Armenian Prime Minister Nikol Pashinyan, Azerbaijani President Ilham Aliyev and Russian President Vladimir Putin announced the deal in the early hours of Tuesday.
Pashinyan described the agreement as "unspeakably painful for me and for our people", while Aliyev said it amounted to a "capitulation" by Armenia.
The full text of the deal showed clear gains for Azerbaijan.
Its forces will retain control over areas seized in the fighting, including the key town of Shusha, while Armenia agreed to a timetable to withdraw from large parts of Nagorno-Karabakh.
Nearly 2,000 peacekeepers
A Russian force of 1,960 military personnel and 90 armoured personnel carriers will deploy to the region as peacekeepers, for a renewable five-year mission.
Aliyev said key ally Turkey would also be involved in peacekeeping efforts but there was no mention of it in the agreement.
Armenian defence ministry spokeswoman Shushan Stepanyan said that "combat operations on the whole frontline are suspended".
The conflict over the territory — which has simmered for decades despite international efforts to reach an accord — erupted into fresh fighting in late September.
More than 1,400 people have been confirmed killed, including dozens of civilians, but the death toll is believed to be significantly higher.
Azerbaijani forces made steady gains over the weeks of fighting, sweeping across the southern flank of the region and eventually into its heartland.
A turning point came on Sunday when Aliyev announced that his forces had captured Shusha, the region's strategically vital second-largest town.
Olga Oliker of the International Crisis Group said although the deal ends weeks of fighting "it is not a comprehensive peace treaty. Many details remain vague."
"Disquiet in Baku among those who see Russian peacekeepers as an encroachment on its sovereignty may test the deal," she added.
The announcement caused outrage in Yerevan, with angry protesters storming government headquarters where they ransacked offices and broke windows.
Crowds also entered parliament and demanded Pashinyan's resignation.
Police retook control of both buildings but the opposition called for a protest on Wednesday against Pashinyan, who came to power leading peaceful protests in 2018.
Pashinyan said he was personally responsible for the Karabakh "catastrophe," but defended his decision saying the situation could only have got worse.
"It is necessary to draw lessons, this will help Armenia's future development."
In the Azerbaijani capital Baku joyful residents took to the streets chanting "Karabakh! Karabakh!" and waving Azerbaijani and Turkish flags.
"I am very happy, congratulations to the motherland, I hope these lands will be ours forever," said Elnar Hajiyev, waving an Azerbaijani flag as passing cars honked in celebration.
Karabakh declared independence nearly 30 years ago but it has not been recognised internationally, even by Armenia, and remains a part of Azerbaijan under international law.
Attempts at ceasefires brokered by France, Russia and the United States — which together lead the "Minsk Group" that sought for years to end the conflict — repeatedly failed over recent weeks.
The latest agreement made no mention of the status of the Armenian-populated areas of Nagorno-Karabakh or of the format of future negotiations to settle the conflict.
Azerbaijan has been pushing for Turkey's involvement in a settlement and the new deal came after Putin spoke with Turkish President Recep Tayyip Erdogan on Saturday.
"Our dear Azerbaijan achieved significant gains in the field and at the (negotiating) table. I wholeheartedly congratulate this blessed success," tweeted Turkish Foreign Minister Mevlut Cavusoglu.
The agreement also provides for Armenia to agree to a transport corridor linking Azerbaijan with its Nakhchivan exclave on the border with Turkey.
French President Emmanuel Macron expressed hope that the deal will "preserve Armenia's interests" and also called on Turkey to "end its provocations" over the conflict.
The ceasefire deal came just hours after Azerbaijan admitted to accidentally shooting down a Russian military helicopter flying in Armenia near Nakhchivan and quickly apologised.
Iran welcomed the deal to end the fighting and called for "foreign fighters" to pull out of the region, a reference to widespread allegations that Ankara had dispatched mercenaries from Syria to bolster Azerbaijan's forces.
Russia has a military pact with Armenia but also good ties with oil-rich Azerbaijan, both ex-Soviet countries that gained independence with the 1991 collapse of the USSR.