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.

The announcement of a full ceasefire from 1:00 am Tuesday (2100 GMT) sparked outrage in Armenia, with angry protesters storming the government headquarters in Yerevan where they ransacked offices and broke windows.

Shusha in Azerbaijan, Armenia War
The capture of Shusha would be a major victory for Azerbaijan Photo: AFP / Karen MINASYAN

Thousands gathered outside the building, calling for the resignation of Prime Minister Nikol Pashinyan after he announced the "painful" deal to the end the fighting.

"I have signed a statement with the presidents of Russia and Azerbaijan on the termination of the Karabakh war," Pashinyan said, calling the move "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 said, calling the ceasefire "the best possible solution".

Armenia and Azerbaijan war
Military volunteers walk on a forest road in the Shusha region on October 31, 2020 Photo: AFP / Davit GHAHRAMANYAN

Azerbaijan's President Ilham Aliyev said Pashinyan had been left with no choice but to sign the "historic agreement".

"An iron hand forced him to sign this document," Aliyev said in televised remarks. "This is essentially a capitulation."

Aliyev said the agreement gave Armenia a short timeframe to withdraw its troops from parts of Nagorno-Karabakh and that Russia and Azerbaijan's ally Turkey would be involved in implementing the ceasefire.

Russian President Vladimir Putin confirmed that both sides had agreed to "a total ceasefire... in the Nagorno-Karabakh conflict zone".

Azerbaijan President
Azerbaijan President Ilham Aliyev announced Sunday his forces had taken Shusha Photo: Azerbaijani Presidential Press Office / Handout

The deal would end six weeks of fierce clashes over Nagorno-Karabakh, an ethnic Armenian region of Azerbaijan that broke away from Baku's control during a bitter war in the 1990s.

The conflict -- which simmered for decades despite international efforts to reach a peace deal -- erupted into fresh fighting in late September.

At least 1,000 people have been confirmed killed, including dozens of civilians, but the actual death toll is believed to be significantly higher.

Armenia and Azerbaijan war
Angry protesters gather at Armenian govt headquarters Photo: AFPTV / Karen MINASYAN

Azerbaijani forces made steady gains over the weeks of fighting, sweeping across the southern flank of Nagorno-Karabakh and eventually into the region's 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-Karbakh's main city Stepanakert and on the main road to Armenia, which backs the separatists.

Armenia insisted earlier on Monday that fighting for the town was continuing but a local separatist official admitted that Shusha was "completely out of our control".

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 by a man-portable air defence system close to the border with Azerbaijan. A third crew member was injured and evacuated, it said.

Azerbaijan quickly apologised for the "tragic incident" saying the mistake was the result of the "tense situation in the region and increased combat readiness" of its forces.

The helicopter was shot down near the Nakhchivan Autonomous Republic, a landlocked exclave of Azerbaijan between Armenia and Turkey, far from Nagorno-Karabakh.

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.

Anger had already been mounting in Armenia ahead of the deal, with 17 opposition parties on Monday calling on Pashinyan and the rest of his government to immediately resign.

The parties -- including several of the country's largest political groupings -- said in a statement that Armenia's leaders bore "the entire responsibility for the situation" in Karabakh.

"The authorities have lost their moral and political basis to represent the people," they said.

Copyright AFP. All rights reserved.