1128 GMT February 29, 2020
Erdogan held talks with Hungarian nationalist Prime Minister Viktor Orban – a rare EU ally – in Budapest where several hundred people demonstrated over Ankara's military offensive in Syria, AFP reported.
Ankara launched the military operation last month to push Syrian Kurdish forces back from its border and create a "safe zone" to take in some of the 3.6 million Syrian refugees currently in Turkey.
Erdogan has called on EU countries to provide more financial support for his plan to create the "safe zone".
"Whether or not support comes, we will continue to host our guests, but only up to a point," Erdogan said at a news conference alongside Orban.
"If we see that this does not work, just like I said before, we will have no option left but to open the gates. If we open the gates, it is obvious where they will go," Erdogan added.
Orban, an anti-immigration figurehead for nationalists in Europe and beyond, said Hungary stood ready to help Turkey however it could to create the "safe zone".
"Without Turkey, you cannot stop migration headed for Europe... As a consequence of this, Hungary is a strategic partner of Turkey in security and migration questions," he said.
"We have to do everything to avoid masses of migrants arriving at Hungary's southern border, and for that we need Turkey's help."
Erdogan's visit comes just a week after Orban hosted Russian President Vladimir Putin.
Speaking alongside Putin, also a regular visitor to the EU and NATO member state, Orban defended his foreign policy of "eastern opening", saying Hungary was in a "Berlin-Moscow-Istanbul triangle".
Accusing his Western critics of turning a blind eye to their own countries' trade and political engagements with eastern countries, Orban has repeatedly defended Ankara.
Hungary delayed an EU resolution condemning Turkey's action, with Orban insisting that the offensive was in "Hungary's national interest" because it would help stop refugees coming to the EU.
At a meeting in Kazakhstan last month, Erdogan personally thanked Orban for his "support" for Ankara's Syrian operation.