The UN's top court ordered rivals Armenia and Azerbaijan Tuesday to prevent racial hatred and avoid aggravating their feud following last year's war between the Caucasus arch-foes.

Azerbaijan was also told to protect Armenian prisoners from the 2020 Nagorno-Karabakh conflict, and to stop the desecration of Armenian cultural heritage, including churches.

The former Soviet republics had both made tit-for-tat requests asking the International Court of Justice (ICJ) in The Hague to take emergency measures against alleged breaches of a treaty banning racial discrimination.

"Both parties shall refrain from any action which might aggravate or extend the dispute before the court or make it more difficult to resolve," ICJ chief judge Joan Donoghue said.

The court's orders -- which are binding even though the ICJ has no real means of enforcing them -- are pending a full case on the row that could take years to resolve.

The ICJ was set up after World War II to resolve disputes between United Nations member states.

Armenia handed Lachin district to Azerbaijan as part of a peace deal that ended six weeks of fighting over the breakaway region of Nagorno-Karabakh
Armenia handed Lachin district to Azerbaijan as part of a peace deal that ended six weeks of fighting over the breakaway region of Nagorno-Karabakh AFP / Karen MINASYAN

Tensions have simmered for years over Nagorno-Karabakh, an ethnic Armenian region of Azerbaijan that broke away from Baku's control in the early 1990s after the collapse of the Soviet Union.

Conflict erupted in autumn last year, claiming more than 6,500 lives. It ended in November with a Russian-brokered ceasefire under which Armenia ceded territories it had controlled for decades to Turkish-backed Azerbaijan.

Judges on Tuesday ordered Azerbaijan to "protect from violence and bodily harm" all Armenian prisoners from the conflict and ensure they are treated lawfully, following allegations of mistreatment.

Azerbaijan must further prevent the "vandalism and desecration" of Armenian cultural heritage including churches, it said.

Tensions have simmered for years over Nagorno-Karabakh, an ethnic Armenian region of Azerbaijan that broke away from Baku's control in the early 1990s
Tensions have simmered for years over Nagorno-Karabakh, an ethnic Armenian region of Azerbaijan that broke away from Baku's control in the early 1990s AFP / ARIS MESSINIS

Baku had already ordered the removal of wax mannequins of Armenian troops from Azerbaijan's so-called Military Trophies Park, which Armenia had requested due to their "Armenophobic features", the court said.

The ICJ further ordered both Azerbaijan and Armenia to "take all necessary measures to prevent the incitement and promotion of racial hatred and discrimination" against the other.

In Azerbaijan's case the order involved "officials and institutions", whereas for Armenia the court mentioned "organisations and private persons".

Azerbaijan's foreign ministry welcomed the ruling.

"Azerbaijan will comply with the measures indicated by the court related to preventing racial discrimination," it said in a statement, urging Armenia to do the same.

"Azerbaijan will continue to uphold the rights of all people under international law, and to hold Armenia to account for its ongoing and historic grave violations of human rights," it however added.

There was no immediate reaction from Yerevan.

The ICJ however threw out a bid by Azerbaijan to make Armenia stop laying landmines and to hand over maps of mines, saying that it was not covered by the anti-discrimination treaty.

During hearings in October, Armenia and Azerbaijan both accused the other of breaching a UN treaty at the centre of several ICJ cases, the International Convention on All Forms of Racial Discrimination.

Armenia accused Azerbaijan during those hearings of fuelling a "cycle of hate" while Azerbaijan meanwhile accused Armenia of "ethnic cleansing".

Azerbaijan said on Saturday it had freed 10 Armenian soldiers captured last month during fresh fighting, following Russian-mediated talks.

Armenia in exchange passed on maps of mine fields.

The swap came after Azerbaijan's President Ilham Aliyev and Armenia's Prime Minister Nikol Pashinyan agreed to ease tensions last week at a rare meeting in Russia's Black Sea resort of Sochi.