Russian and Ukrainian delegations signed individual agreements with Ankara and the UN in the wake of several rounds of laborious negotiations.
Kyiv and Moscow on Friday penned a landmark agreement with Turkey and the United Nations Friday to unblock Ukraine's Black Sea grain exports after a Russian blockade raised fears of a global food crisis.
In their first major deal after nearly five months of fighting, Russian and Ukrainian delegations signed individual agreements with Ankara and the UN in the wake of several rounds of laborious negotiations.
Ukraine had warned ahead of the signing that any Russian "provocations" around its encircled Black Sea ports would be met with a swift military response and refused to pen the same papers as Moscow.
"Today, there is a beacon on the Black Sea -- a beacon of hope, a beacon of possibility, a beacon of relief," UN Secretary General Antonio Guterres said at the signing ceremony in the lavish Dolmabahce Palace on the Bosphorus Strait.
The deal agreed through UN and Turkish mediation establishes safe corridors along which Ukrainian ships can come in and out of three designated Black Sea ports in and around Odessa.
And both sides also pledged not to attack ships on the way in or out.
"It will bring relief for developing countries on the edge of bankruptcy and the most vulnerable people on the edge of famine," Guterres said.
The five-month war, which has displaced millions and left thousands dead, is being fought across one of Europe's most fertile regions by two of the world's biggest grain producers.
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.
"Today's Istanbul agreement is a step in the right direction. We call for its swift implementation," tweeted the bloc's foreign policy chief Josep Borrell.
Turkish President Recep Tayyip Erdogan -- a key player in the negotiations who has good relations with both Moscow and Kyiv -- said he hoped the deal would "hopefully revive the path to peace".
UK Foreign Secretary Liz Truss congratulated Turkey and the UN for brokering the deal but cautioned "we will be watching to ensure Russia's actions match its words".
Earlier, Ukrainian presidential aide Mykhaylo Podolyak explained the two sides would sign "mirror" agreements.
"We sign an agreement with Turkey and the UN and undertake obligations to them. Russia signs a mirror agreement with Turkey and the UN," he said on social media.
He warned that Russian breaches of the deal and incursions around Ukraine's ports would be met with "an immediate military response".
Diplomats expect grain to start fully flowing for the first time since Russia's invasion of its Western-backed neighbour by the middle of August.
Also read: South Africa turns to Russia for food
Still, news of the deal earlier drew scepticism from Ukrainian farmers under pressure in the war-battered south where storage facilities are rapidly filling and local prices for grain tanking.
"It gives some hope but you can't believe what the Russians say," said Mykola Zaverukha, a farmer with some 13,000 tonnes of grain waiting for export.
"Russia is unreliable, they have shown themselves to be year after year," he told AFP in the southern Mykolaiv region.
The Kremlin said earlier it was hoped the parties would arrive at an understanding.
"It is very important to unblock supplies of fertilisers, foodstuffs and grain to the world markets," spokesman Dmitry Peskov told reporters Friday morning.
US State Department spokesman Ned Price welcomed news of the deal Thursday but said "we should never have been in this position in the first place," and accused Russia of "weaponising" food.
The landmark signing in Istanbul however brought little relief across Ukraine's sprawling frontline and Russian forces were pursuing a relentless shelling campaign in the eastern Donetsk region.
The presidency said five people had been killed and twice as many injured in Russian attacks on the industrial region -- the centre of recent fighting -- the previous day.
In the Donetsk village of Chasiv Yar, which was hit by a strike on July 10 that killed more than 45 people, a 64-year-old woman gathered apricots near the wreckage.
"There is nothing anymore. The officials have left. We have to fend for ourselves to stay alive," said Lyudmila, who only gave her first name.
In the south, Ukraine said Russian forces were shelling villages along the frontline in the Kherson area, where Kyiv's army is trying to claw back Moscow-occupied territory.
The parties were convening in Istanbul one day after Russia's restart of the Nord Stream gas pipeline eased concerns in Europe of a permanent shut off after 10 days of repairs.
Yet even the resumption of 40 percent of supplies would be insufficient to ward off energy shortages in Europe this winter, experts warned.
The military toll on both sides has remained speculative at best since Russia invaded on February 24.
Some 15,000 Russians have died in the invasion, US and British spy chiefs said, as they assessed that President Vladimir Putin was suffering far greater losses than expected.