Russia and Ukraine have defied the odds and struck a deal to reopen Ukrainian Black Sea ports for grain exports, raising hopes that a global food catastrophe might be averted.

The essence of the deal, backed by the UN and Turkey and signed in Istanbul today, is that Russia won’t target ports while shipments are in transit, and Ukrainian vessels will guide cargo ships through mined waters. Turkey and the UN will check ships for smuggled weapons.

“We’ve been working around the clock with intense behind the scenes talks with countless moving parts,” said Farhan Haq, a UN spokesman. With an agreement, he added: “We can potentially save hundreds of thousands, potentially millions of people, from having food be priced out of their reach.”

Ukraine is one of the world’s major grain exporters. Some 20 million tons of grain desperately needed around the world is stuck in silos in the port of Odessa. Lebanon, for instance, relies on Ukraine for 80 per cent of its grain imports.

Russia’s occupation has restricted grain shipments and sent global prices soaring. Putin’s forces have blockaded Black Sea ports, including Odessa, while Ukraine has mined coastal waters to prevent an amphibious invasion.

Today’s agreement is the first successful mediation between the two sides since the conflict began. Turkey’s President Erdogan said that he hoped the grain deal could pave the way for a Turkey-brokered peace deal, after previous attempts failed.

But the signs don’t look great. The Ukrainian and Russian defence ministers refused to be in the same room as one another – each side signed the deal with Turkey and the UN, rather than each other.

“Any guarantees that Russia may give to anyone are not considered valid,” said President Volodymyr Zelensky’s adviser, Mykhailo Podolyak. “We do not pay attention to them. There are guarantors – Turkey and the UN – and we work with them.”

Even so, it’s a coup for Erdogan, whose tight-rope walking with Moscow and the West seems to have paid off. Russia also stands to gain. The “package deal” will facilitate grain and fertiliser shipments from Russia which are under indirect restrictions, despite not being sanctioned by the West.   

Yet negotiating the terms may have been the easy bit. There are plenty of practical sticking points that could prevent grain from leaving Ukraine. Shipping firms have got to trust both sides to honour the agreement before they start exporting. The extent of damage to ports is unclear, and it could take weeks for exports to resume, even if the two sides stick to the deal.

The world’s hungry aren’t out of the woods yet. Markiyan Dmitrasevych, Ukraine’s deputy agriculture minister, says Ukraine still lacks storage for between 15 and 18 million tons of grain for this autumn’s 60-million-ton harvest.  Even so, the deal marks a rare victory for diplomacy in a brutal war now entering its sixth month.