Erdogan made the announcement one day before it had been due to expire, scoring a diplomatic coup ahead of a May 28 runoff election in which he will try to extend his two-decade rule until 2028.
He thanked "my precious friend", Russian President Vladimir Putin, Ukrainian counterpart Volodymyr Zelensky and UN Secretary General Antonio Guterres for their roles in extending the agreement.
"With the efforts of our country, the support of our Russian friends, the contribution of our Ukrainian friends, it was decided to prolong the Black Sea grain deal for two more months," Erdogan said in nationally televised remarks.
Erdogan said Russia had agreed not to block ships from leaving two Ukrainian harbours, expressing hope that the deal would be "beneficial for all the parties".
Kyiv said it was "grateful" to the United Nations and Turkey for their efforts in "strengthening food security".
"These agreements matter for global food security -- Ukrainian and Russian products feed the world," Guterres said, while stressing the need for a more comprehensive, longer-term agreement.
But Russia denounced what it called "disparities" in the implementation of the deal that "should be corrected as quickly as possible".
Ukraine was one of the world's major grain exporters before Russia invaded in February last year.
Russian warships blockaded Ukraine's Black Sea ports, sending food prices soaring on global markets and disproportionately hitting the world's poorest.