Ukraine and Russia have signed "mirror" deals which will allow Kyiv to resume exports of grain through the Black Sea.
The agreement will allow millions of tonnes of grain, currently trapped in Ukraine by the war, to be exported.
The world shortage of Ukrainian grain since Russia's 24 February invasion has left millions at risk of hunger.
However, Kyiv refused to sign a direct deal with Moscow, and warned "provocations" would be met with "an immediate military response".
Both sides attended the signing ceremony in Istanbul but did not sit at the same table. Russia's Defence Minister Sergei Shoigu signed Moscow's deal first, followed by Ukrainian Infrastructure Minister Oleksandr Kubrakov signing Kyiv's identical agreement.
The blockade of Ukraine's grain has caused a global food crisis with wheat-based products like bread and pasta becoming more expensive, and cooking oils and fertiliser also increasing in price.
Mr Shoigu told a news conference earlier the deal might allow "the solutions to start this process in the coming days".
"I'm talking not only about beginning the export of agricultural products from Ukrainian ports but clearly also work in this direction on the export of agricultural products and fertilisers from Russian ports," he added.
According to diplomats, under the terms of the deal:
UN Secretary General Antonio Guterres told the BBC's Orla Guerin it was probably the most important thing he had done in his time heading the international body.
The grain export deal will also come as a big relief to the Horn of Africa, the BBC's Anne Soy says from Nairobi, Kenya. The region is currently facing serious food shortages caused by drought, and exacerbated by the Covid-19 pandemic, a rare locust invasion and the war in Ukraine.
Samantha Power, the US development agency's administrator, said the deal was "an extremely important piece of a puzzle" in solving the region's crisis.
Meanwhile, Turkey's President Recep Tayyip Erdogan - who has played a crucial role in negotiations - said he hoped the deal might be the first step towards bringing the war to an end.
"This joint step we are taking with Ukraine and Russia will hopefully revive the path to peace," he said.
Mr Guterres was less positive, saying: "At the present moment, I see no conditions for a peace process."
Source: BBC News