Turkish President Recep Tayyip Erdogan has warned the European Union that if it continues threatening his country he will open the border gates and allow hundreds of thousands of migrants to flood into EU countries.

Erdogan, in a speech Friday, reacted furiously to a non-binding resolution approved the previous day by the European Parliament demanding that the bloc freeze membership negotiations with Turkey over the government's heavy-handed crackdown following a failed coup in July.

"We are the ones who feed 3-3.5 million refugees in this country. You have betrayed your promises," Erdogan told the EU. "If you go any further those border gates will be opened."

The EU struck a deal earlier this year to return migrants to Turkey in return for a package including aid for the refugees and accelerated membership talks.