Hundreds of Russian peacekeeping troops have been deployed to the disputed enclave of Nagorno-Karabakh, following a deal to end conflict in the region.
Heavy fighting between Azerbaijani and ethnic Armenian forces had been ongoing for weeks, until both sides agreed to a Russian-brokered peace deal on Monday.
The enclave is internationally recognised as Azerbaijani but has been run by ethnic Armenians since 1994.
The peace deal sparked jubilant scenes in Azerbaijan and fury in Armenia.
Under its terms, Azerbaijan will hold on to several areas that it has taken during the conflict. Armenia also agreed to withdraw from several other adjacent areas over the next few weeks.
The BBC's Orla Guerin in Baku says that, overall, the deal should be read as a victory for Azerbaijan and a defeat for Armenia.
Protesters in Armenia have damaged official buildings and called for the resignation of Prime Minister Nikol Pashinyan.
What else has been agreed?
The peace deal, which was signed by Russian President Vladimir Putin, Azerbaijani President Ilham Aliyev and Armenia's prime minister, took effect on Tuesday from 01:00 local time (21:00 GMT Monday).
During a televised online address, President Putin said that Russian peacekeepers would be deployed to patrol the front line. Ten aircraft carrying the first wave of troops took off from an airbase in Ulyanovsk early on Tuesday.
At least 2,000 Russian soldiers will eventually be active in the region and they will guard the "Lachin corridor" which links the Karabakh capital, Stepanakert, to Armenia. Ninety armoured personnel carriers will also deploy as part of the renewable five-year mission.
Mr Putin said the agreement would include an exchange of war prisoners, with "all economical and transport contacts to be unblocked."
Moscow is in a military alliance with Armenia and has an army base there, but it also has close ties with Azerbaijan and it has been selling weapons to both countries.
Turkey, which has openly backed Azerbaijan, will also take part in the peacekeeping process, according to Azerbaijan's president who joined Mr Putin during the address. However the exact role Turkey will play is unclear.
Jubilant scenes in Azerbaijan
By Orla Guerin, BBC News, Baku
There is a mood of national celebration in Baku. At Martyrs' Alley - a memorial to Azerbaijan's fallen soldiers - there are surging crowds among a sea of flags.
There is a real sense here that a key victory has been achieved after a very long fight. Groups are breaking out in chants and singing the national anthem.
Two young students are holding a homemade sign that reads: "Tell the world we are coming home." It is a home they have never seen. Their parents were driven from Nagorno-Karabakh almost 30 years ago, but now they intend to move there to build a new life.
Asked if they could imagine living side by side with Armenians, one replied that this might take decades. "Our children may see this," she told me.
How did the deal come about?
Although both sides took steps to reduce tensions last year, fighting erupted at the end of September and several attempts to end the conflict failed.
Over the weekend, Azerbaijan said it had taken control of the key town of Shusha, known as Shushi in Armenian.
The town is strategically important because it could serve as a well-positioned staging post for an attack on Nagorno-Karabakh's main city of Stepanakert, military analysts say.
While Armenia denied the town had been lost, on Tuesday Nagorno-Karabakh's ethnic Armenian leader Arayik Harutyunyan said his forces had little choice but to sign a peace deal given the situation on the ground.
Battles were already taking place on the outskirts of Stepanakert and if the conflict had continued the whole of Karabakh would have been lost, he said on Facebook. "We would have far more losses," he said.
Meanwhile Mr Pashinyan, Armenia's Prime Minister, said signing the deal was "incredibly painful both for me and for our people".
He added: "The decision was made based on a deep analysis of the combat situation and in conjunction with the best experts."
Azerbaijan's President Aliyev, meanwhile, said the agreement was of "historic importance," and amounted to a "capitulation" by Armenia.
Turkey's Foreign Minister Mevlut Cavusoglu hailed it as a "sacred success".
But France's Emmanuel Macron expressed hope that the deal would "preserve Armenia's interests" and called on Turkey to "end its provocations" over the conflict.
France is home to a large Armenian community and Mr Macron said the country "stands by Armenia at this difficult time".
Defeat sparks crisis in Armenia
By Yuri Vendik, BBC Russian, Yerevan
It was a night of unrest and upset in Armenia's capital, where crowds of protesters stormed government buildings and the country's parliament.
But by Tuesday morning, that anger appeared to have died down.
Leading politicians, with the exception of Prime Minister Nikol Pashinyan, are in talks to find a way out of this deep crisis. And this is a crisis: the defeat in Nagorno-Karabakh is a devastating one
The protesters who gathered here overnight accused the government of betrayal. They believed the fighting should have continued until the end and they were confident of victory.
But in Nagorno-Karabakh itself there was no such optimism. The leadership of the enclave earlier admitted that, had the fighting continued, the main city of Stepanakert would have been lost within days.
How deadly was the conflict?
It is unclear exactly how many have died during the flare-up in fighting. Both sides deny targeting civilians but accuse the other of doing so.
Nagorno-Karabakh's authorities say nearly 1,200 of its defence forces have died in the fighting, and civilians have also been killed or injured.
Azerbaijan has not released its military casualty figures but has said more than 80 civilians were killed in the fighting - including 21 in a missile strike on the town of Barda last month.
Russia's Vladimir Putin said last month that almost 5,000 people had been killed in the fighting.