Ukraine and Russia on Friday ended months of fraught negotiations and signed a landmark deal with Turkey and the United Nations aimed at relieving a global food crisis caused by blocked Black Sea grain deliveries.
The first major deal between the warring parties since Russia's February invasion should help ease the "acute hunger" that the UN estimates say now faces an additional 47 million people because of the war.
But the hostility between Moscow and Kyiv spilled over into the signing ceremony -- delayed for more than half an hour by disputes about the display of flags around the table and Ukraine's refusal to put its name on the same document as the Russians.
The two sides eventually inked separate but identical agreements in the presence of UN Secretary General Antonio Guterres and Turkish President Recep Tayyip Erdogan at Istanbul's lavish Dolmabahce Palace on the Bosphorus Strait.
"Today, there is a beacon on the Black Sea -- a beacon of hope, a beacon of possibility, a beacon of relief," Guterres said moments before Russian and Ukrainian officials penned their separate deals.
Turkish President Recep Tayyip Erdogan -- a key player in the negotiations who has good relations with both Moscow and Kyiv -- said the deal would "hopefully revive the path to peace".
But Ukraine entered the ceremony by bluntly warning that it would conduct "an immediate military response" should Russia violate the agreement and attack its ships or stage an incursion around its ports.
Ukrainian President Volodymyr Zelensky later said the responsibility for enforcing the deal would fall to the UN.
- 25 million tonnes of wheat -
The agreement includes points on running Ukrainian grain ships along safe corridors that avoid known mines in the Black Sea.
Up to 25 million tonnes of wheat and other grain have been blocked in Ukrainian ports by Russian warships and landmines Kyiv has laid to avert a feared amphibious assault.
Wheat prices tumbled Friday to levels seen before Russia's invasion of Ukraine, following the agreement -- even as some analysts expressed scepticism about the accord.
In Chicago, the price of wheat for delivery in September dropped 5.9 percent to $7.59 per bushel, equivalent to about 27 kilograms. Prices in Europe fell by a similar amount.
Russian Defence Minister Sergei Shoigu told Kremlin state media after attending the signing ceremony that he expected the deal to start working "in the next few days".
He pointed out that Russia had managed to secure a separate pledge from Washington and Brussels to lift all restrictions on its own grain and other agricultural exports.
Western powers hailed the agreement while urging Moscow to closely abide by its rules.
A US official said the deal was "well-structured" enough to monitor Russia compliance.
"We fully expect the implementation of today's arrangement to commence swiftly to prevent the world's most vulnerable from sliding into deeper insecurity and malnutrition," White House spokesman John Kirby told reporters.
The European Union called for the deal's "swift implementation" while UK Foreign Secretary Liz Truss said London "will be watching to ensure Russia's actions match its words".
- Guarded hope -
Diplomats expect grain to only start fully flowing by the middle of August.
The four sides must first set up a joint command and control centre in Istanbul that monitors the ships' passage and addresses any disputes.
They have yet to nail down how the ships will be checked for possible weapons before returning empty to Ukrainian ports.
Ukrainian farmers who have been watching their silos fill up with grain that they cannot sell met the Istanbul deal with guarded hope.
"It gives some hope but you can't believe what the Russians say," said farmer Mykola Zaverukha.
His silos were already filled with 13,000 tonnes of grain and in danger of overflowing because this year's harvest was only just starting to come in.
"Russia is unreliable, they have shown themselves to be year after year," he told AFP in the southern Mykolaiv region.
Global alarm about that grain has been accompanied by European fears that Russia is starting to use its stranglehold on energy exports as a geopolitical weapon in its standoff with the West.
The grain deal was signed one day after Russia's restart of the Nord Stream natural gas pipeline eased concerns in Europe of a permanent shut off after 10 days of repairs.
But analysts warn that the partial resumption of gas supplies was insufficient to ward off energy shortages in Europe this winter.
- Mounting Russian losses -
The ornate halls of Istanbul's Dolmabahce Palace felt far removed in east Ukraine's Donbas war zone on another day of relentless shelling across the front.
Russia is trying to fight deeper into the war zone's Donetsk region after securing full control of neighbouring Lugansk.
The Ukrainian presidency said five people were killed and twice as many injured in Russian attacks around the Donetsk region the previous day.
In the Donetsk village of Chasiv Yar -- hit by a strike on July 10 that killed more than 45 people -- 64-year-old Lyudmila was gathering apricots near the wreckage.
"There is nothing anymore. The officials have left. We have to fend for ourselves to stay alive," she said giving only her first tame.
The military toll on both sides has remained speculative at best since Russia invaded on February 24.
But US and British spy chiefs believe Russian President Vladimir Putin was suffering far greater losses than expected.
Ukraine's war effort has been particularly helped in the past few weeks by the delivery of US high-precision weapons that allow Kyiv to destroy Russian weapons silos at long range.