Armenia and Azerbaijan agreed on a deal with Russia to end weeks of fierce clashes over Nagorno-Karabakh on Tuesday, after a string of Azerbaijani victories in its fight to retake the disputed region.
Hundreds of Russian peacekeepers were en route to the ethnic Armenian territory, which broke from Azerbaijan's control during a war in the 1990s, just hours after an early morning ceasefire took effect.
But the agreement sparked outrage in Armenia, with angry protesters storming the government headquarters in the capital Yerevan where they ransacked offices and broke windows.
Crowds also entered parliament and demanded the resignation of Prime Minister Nikol Pashinyan, who earlier described his participation in the accord as "unspeakably painful for me personally and for our people".
"I have taken this decision as a result of an in-depth analysis of the military situation," he added.
Azerbaijan's President Ilham Aliyev said Pashinyan had been left with no choice but to agree.
- 'A capitulation' -
"An iron hand forced him to sign this document," Aliyev said in televised remarks. "This is essentially a capitulation."
Russian President Vladimir Putin confirmed that both Armenia and Azerbaijan had agreed to "a total ceasefire" that would create the conditions for a long-term settlement of the conflict.
He said the two sides would hold on to areas under their control and that Russian peacekeepers would deploy along frontlines and to secure a corridor connecting Nagorno-Karabakh with Armenian territory.
Putin said displaced people would be allowed to return to the region and there would be exchanges of prisoners and bodies from the fighting.
Russian news agencies quoted the defence ministry as saying 1,960 peacekeepers would be deployed with 90 armoured vehicles.
The ministry said several Il-76 aircraft carrying the first peacekeepers and their equipment had taken off from an airfield in Russia.
Aliyev said Armenia had agreed to a timetable to withdraw its forces from large parts of Nagorno-Karabakh and that Azerbaijan's ally Turkey would be involved in implementing the ceasefire.
The conflict over the territory -- which has simmered for decades despite international efforts to reach a peace deal -- erupted into fresh fighting in late September.
More than 1,300 people have been confirmed killed, including dozens of civilians, but the actual death toll is believed to be significantly higher.
- Strategic town seized -
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.
Shusha sits on cliffs overlooking Nagorno-Karabakh's main city Stepanakert and on the main road to Armenia, which backs the separatists.
The ceasefire deal came just hours after Azerbaijan admitted to accidentally shooting down a Russian military helicopter flying in Armenia.
Moscow's defence ministry said two crew members were killed when the Mi-24 helicopter was hit close to the border with Azerbaijan.
Azerbaijan quickly apologised and blamed the incident on the "tense situation in the region and increased combat readiness" of its forces.
- Mounting anger in Armenia -
Russia has a military pact with Armenia and a base in the country, but had insisted it would not get involved in the conflict with Azerbaijan unless Armenian territory itself came under threat.
Karabakh declared independence nearly 30 years ago but the declaration has not been recognised internationally, even by Armenia, and it remains a part of Azerbaijan under international law.
Repeated attempts at ceasefires brokered by France, Russia and the United States -- who together lead the "Minsk Group" that sought for years to end the conflict -- repeatedly failed over recent weeks.
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.
That call echoed through the streets of Yerevan after the deal was announced in the early hours of Tuesday, as protesters shouted "Resign!" and "Traitor!"
Chaotic scenes erupted inside parliament after protesters entered its inner chamber, where arguments and scuffles broke out as people tried to take to the podium and were shouted down, with some throwing bottles.
Pashinyan denied rumours he had fled the country in a Facebook post on Tuesday morning.
"Of course I am in Armenia and fully continue my work as prime minister," he said.