"Following talks with the two parties, we have assured the extension of the deal that was due to expire on March 19," Erdogan said in comments broadcast on Turkish television, just hours before the agreement was due to expire at midnight.
Erdogan did not say for how long the deal was extended. Ankara had previously said it wanted a 120-day extension, while Russia was in favour of a 60-day extension.
"This deal is of vital importance for the global food supply. I thank Russia and Ukraine, who didn't spare their efforts for a new extension, as well as the United Nations secretary general."
Russia's full-scale invasion in February 2022 saw Ukraine's Black Sea ports blocked by warships.
But a deal brokered by Turkey and the United Nations in July 2022 -- and signed by Kyiv and Moscow -- has allowed for the safe passage of exports of critical grain supplies. The initial agreement was extended in November until March 18.
Ukraine was one of the world's top producers, and the so-called Black Sea Grain Initiative has helped soothe the global food crunch triggered by the conflict.