BAKU (Reuters) - Azerbaijan and Armenian-backed separatists said on Friday they had struck a temporary deal to allow each side to safely search for the bodies of their soldiers killed in clashes over the breakaway region of Nagorno-Karabakh.

Slideshow ( 11 images )

The warring parties agreed a ceasefire on Tuesday - with Russian help - after four days of shelling and artillery strikes which killed dozens. The truce has largely held, though both sides have reported some violations.

The violence prompted fears of an all out war in the strategically-important South Caucasus through which Caspian Sea oil and gas is exported to world markets bypassing Russia.

On Friday, the Azeri defense ministry and the Nagorno-Karabakh defense ministry said they had sealed a deal to ensure there were no violations for a five-hour period later in the day to allow both sides to search for their dead.

An official at the Armenian defense ministry used social media to post the names and photographs of 44 separatist soldiers who he said were killed in the clashes since April 2.

Russian Prime Minister Dmitry Medvedev was on Friday in Baku, the capital of Azerbaijan, to hold talks with Ilham Aliyev, the Azeri president, aimed at resuming diplomatic efforts to resolve the territorial dispute.

“Russia, no less than Azerbaijan and Armenia, has an interest in there being peace in this region, our region,” Medvedev said. “The ceasefire agreement is the foundation for unfreezing talks between Baku and Yerevan.”

Any progress towards a permanent settlement of the dispute is likely to be halting.

Nagorno-Karabakh is a mountainous enclave within Azerbaijan’s borders, populated mainly by ethnic Armenians who reject Azerbaijan’s rule. With support from Armenia they fought a war in the early 1990s to establish de facto control over the territory.

The fighting this week was the most intense since a 1994 ceasefire that stopped the conflict but did not resolve the underlying dispute.

Azerbaijan says the only outcome of negotiations it will accept is the restoration of its control over Nagorno-Karabakh and surrounding districts that are held by the separatists, while the Armenians say they will never agree to Nagorno-Karabakh being under Baku’s control.

Medvedev’s visit to Azerbaijan, a day after he was in the Armenian capital for talks, showed Moscow was staking out a lead role in mediating in the conflict.

Russia’s active diplomacy overshadowed the United States, which has extensive interests in the South Caucasus region that includes Azerbaijan and Armenia.