(Reuters) -President Vladimir Putin on Wednesday reserved Russia's right to withdraw again from an international agreement allowing Ukraine to export grain via the Black Sea, after ending four days of non-cooperation with the deal.
If Russia did so, however, Putin said it would not impede shipments of grain from Ukraine to Turkey.
Moscow had on Saturday pulled out of the arrangement, brokered by Turkey and the United Nations, saying it could not guarantee the safety of civilian ships crossing the Black Sea because of a drone attack on its fleet there.
Wednesday's U-turn followed a phone call between Putin and Turkish President Tayyip Erdogan on Tuesday and consultations between their defence ministers.
In a statement, Russia's defence ministry said that, with the help of the United Nations and NATO-member Turkey, it had obtained sufficient written guarantees from Ukraine that it would not use the secure shipping corridor or its designated Ukrainian ports for strikes against Russia.
Putin affirmed the receipt of those commitments, and said that if Russia withdrew once more because of Ukrainian breaches, it would substitute the entire volume of grain destined for the "poorest countries" for free from its own stocks.
But, in a nod to Turkey's influence, as well as what he called its "neutrality" in Russia's conflict with Ukraine, he added: "In any case, we will not in the future impede deliveries of grain from Ukrainian territory to the Turkish Republic."
Moscow had said on Monday it would be risky and unacceptable for ships to continue sailing through the secure corridor set up under the deal, which had freed up Ukrainian ports and shipping lanes that Russia had previously blockaded.
Despite the Russian move, ships had continued to export Ukrainian grain, and a record volume moved on Monday.
"This is quite an unexpected turnaround," said Andrey Sizov, head of the Russia-focused Sovecon agriculture consultancy.
"We did not bury this deal, but we did not expect Russia's return to it so soon either, as it was not very clear what kind of guarantees Russia could get and how quickly it would happen. But, well, good job Erdogan."
Even after the call with the Turkish leader, the Kremlin had said Moscow would only consider resuming the agreement after a "detailed investigation" of a drone attack on Saturday against its Black Sea Fleet in the Crimean port of Sevastopol, which it accused Ukraine of carrying out with support from Britain.
Kyiv has not claimed responsibility for the attack and denies using the humanitarian corridor for military purposes. Britain has denied involvement and accused Russia of trying to divert attention from its military failures in Ukraine.
Russian political analyst Tatiana Stanovaya said Wednesday's announcement represented an acknowledgement by Putin that he could not block the shipments.
"The Kremlin itself simply fell into a trap from which it did not know how to get out," she said.
"It was necessary to retreat and put on a good face (not very successfully) when faced with a bad game. That is, Putin, no matter how preoccupied he is with Ukraine, his historical mission and his faith that he's right, remains a moderately rational politician who knows how to retreat if necessary."
(Additional reporting by Polina Devitt, writing by Mark Trevelyan, editing by Guy Faulconbridge/Andrew Osborn)