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 deal - which took two months to reach - is set to last for 120 days, with a co-ordination and monitoring centre to be established in Istanbul, staffed by UN, Turkish, Russian and Ukrainian officials. It can be renewed if both parties agree.
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.
The US called on Russia to act quickly, with White House spokesman John Kirby saying it was necessary "to prevent the world's most vulnerable from sliding into deeper insecurity and malnutrition".
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:
- Russia will not target ports while shipments are in transit
- Ukrainian vessels will guide cargo ships through waters that have been mined
- Turkey - supported by the United Nations - will inspect ships, to allay Russian fears of weapons smuggling
- Russian exports of grain and fertiliser via the Black Sea will be facilitated.
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.
"Today, there is a beacon on the Black Sea," he told the audience gathered in Istanbul. "A beacon of hope."
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."