Armenian Prime Minister Nikol Pashinyan addresses the nation in Yerevan, Armenia

Armenian Prime Minister Nikol Pashinyan first announced the signing on social media in the early hours of Tuesday and the Kremlin and Azerbaijan’s president Ilham Aliyev later confirmed the news

Armenia, Azerbaijan and Russia said they have signed a deal to end the military conflict over the Nagorno-Karabakh region after more than a month of bloodshed.

Armenian Prime Minister Nikol Pashinyan first announced the signing on social media in the early hours of Tuesday and the Kremlin and Azerbaijan’s president Ilham Aliyev later confirmed the news.

“The signed trilateral statement will become a (crucial) point in the settlement of the conflict,” Aliyev said in a televised online meeting with Russian President Vladimir Putin.

Putin said Russian peacekeepers would be deployed along the frontline in Nagorno-Karabakh and the corridor between the region and Armenia.

Arayik Harutyunyan, the leader of the Nagorno-Karabakh region, said on Facebook that he gave agreement “to end the war as soon as possible”.

The declaration has followed six weeks of heavy fighting and advancement by the Azerbaijan’s forces. Baku said on Monday it had seized dozens more settlements in Nagorno-Karabakh, a day after proclaiming victory in the battle for the enclave’s strategically positioned second-largest city.

“The decision is made basing on the deep analyses of the combat situation and in discussion with best experts of the field,” Prime Minister Pashinyan said.

“This is not a victory but there is not defeat until you consider yourself defeated. We will never consider ourselves defeated and this shall become a new start of an era of our national unity and rebirth.”

Armenian protesters marched to the prime minister’s official residence in Yerevan, Government House No. 1, after the ceasefire was announced, said local news outlet Norlur.am.

Videos seen on social media showed crowds inside the building, but the prime minister’s location was unclear.

The Nagorno-Karabakh fighting has raised fears of a wider regional war, with Turkey supporting its ally Azerbaijan, while Russia has a defence pact with Armenia and a military base there.

Azerbaijan says it has since Sept. 27 retaken much of the land in and around Nagorno-Karabakh that it lost in a 1991-94 war which killed an estimated 30,000 people and forced many more from their homes. Armenia has denied the extent of Azerbaijan’s territorial gains.

Several thousand people are feared killed in the flare-up of the conflict. Three ceasefires have failed in the past six weeks and Azerbaijan’s superior weaponry and battlefield gains have reduced its incentive to seek a lasting peace deal.

Azerbaijan said on Sunday it had captured Shusha, known by Armenians as Shushi, which sits on a mountaintop overlooking Stepanakert, the city regarded as the enclave’s capital by its ethnic Armenian administration.

President Aliyev announced a list of 48 settlements he declared liberated on Monday in several parts of the enclave.

An Azeri defence ministry video posted online showed Azerbaijan’s national flag flying over deserted streets in what it said was Shusha.