Russia said on Wednesday it would renew its participation in an agreement allowing Ukraine to export grain via the Black Sea, just four days after suspending its role in the deal.
Moscow had pulled out at the weekend, saying it could not guarantee the safety of civilian ships crossing the Black Sea because of a drone attack on its fleet there.
"The Russian Federation considers that the guarantees received at the moment appear sufficient, and resumes the implementation of the agreement," the defence ministry said in a statement.
The U-turn followed a phone call between Russian President Vladimir Putin and Turkish President Tayyip Erdogan on Tuesday, and after consultations between their defence ministers.
"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, which it accused Ukraine of carrying out with support from Britain.
Kyiv has not claimed responsibility for the attack and denies using the grain programme's security corridor for military purposes. Britain has denied involvement and accused Russia of trying to divert attention from its military failures in Ukraine.
In Wednesday's statement, Russia's defence ministry said that thanks to the involvement of the United Nations and Turkey, it had been possible to obtain written guarantees from Ukraine that it would not use the humanitarian corridor or Ukrainian ports to conduct military operations against Russia.
Moscow had said on Monday it would be risky and unacceptable for ships to continue sailing through the humanitarian corridor set up under the Turkish- and UN-brokered 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.
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."