It was not immediately clear how long the ceasefire, due to enter into force at midday local time, would last, and there were reports from both sides on Saturday morning of continued fighting.
The Moscow ceasefire talks was the first diplomatic contact between the two sides since fighting over the mountainous enclave, which is internationally-recognised as part of Azerbaijan but is populated and governed by ethnic Armenians, erupted on Sept. 27, killing hundreds of people.
In a statement in the early hours of Saturday after 10 hours of talks, Russian Foreign Minister Sergei Lavrov, who helped mediate between the two sides, said the ceasefire had been agreed on humanitarian grounds.
The International Committee of the Red Cross would help make the truce work, he said.
“The specific terms of the ceasefire still need to be agreed,” said Lavrov, who said that Armenia and Azerbaijan had also agreed to enter into what he called substantive peace talks.
Those talks would be held under the auspices of the Organisation for Security and Co-operation in Europe’s (OSCE) Minsk Group, he said.
Armenian Foreign Minister Zohrab Mnatsakanyan and his Azeri counterpart Jeyhun Bayramov did not speak to reporters in Moscow after striking the ceasefire deal.
But Mnatsakanyan later paid tribute on Armenian state TV to Russian President Vladimir Putin, who he said had played a key role in making sure the talks happened and had personally intervened to help get an agreement.