The decibel level of President Recep Tayyip Erdogan’s denunciations are invariably so high that it is impossible to know how seriously to take them. He has threatened to let loose a wave of three million Syrian and Iraqi refugees who would then try to make their way from Turkey to Europe at a time when anti-immigrant feeling is helping fuel the rise of the populist far right.

Erdogan’s threat came after the European Parliament passed a non-binding resolution to freeze talks on Turkey joining the EU as a protest against Ankara's mass arrest of dissenters in the wake of the failed military coup on 15 July. The purge is extending way beyond those connected to the coup and liberals and Kurds are being detained and the few remaining independent parts of the media are being closed down or brought under control.

The EU correctly talks about “a disproportionate response to the coup" while Erdogan complains that the initial EU condemnation was so tardy and conditional as to suggest that the EU states would have preferred him to be overthrown.

The Turkish leader now says that he may tear up the agreement signed in March to keep potential migrants inside Turkey in return for accelerated talks on Turkey’s EU membership, visa-free travel for Turks coming to Europe and financial aid. “We are the ones who feed 3 million to 3.5 million refugees in this country,” said Erdogan. “You have betrayed your promises. If you go any further those border gates will be opened.”

There is no doubt Erdogan could try to do this, though the threat would have been more potent when it was easier for migrants to move north through the Balkans to central Europe. Border restrictions and fences now make this much more difficult. But the threat of more migrants still has a significant political impact just ahead of the presidential election in Austria in which far-right candidate Norbert Hofer is leading the polls. The success in the US presidential election of Donald Trump’s brand of populist nationalism with a racist cutting edge underlines the extent to which the immigrant wave is resetting the political agenda.

European Parliament votes to block Turkey's attempts to join EU

That said, there is an element of shadow boxing in the latest EU-Turkey row. It probably was not a good idea to link the refugee crisis with progress on Turkey’s faltering decades-old bid to join the EU because it wrapped two insoluble problems into one. It raised hopes in Turkey that were never going to be fulfilled and inevitably brought disappointment. On the other hand, it is not in the interests of the EU or Turkey to escalate their dispute beyond a certain level, even though relations are becoming more antagonistic. Both need each other.

All sides are paying a price for letting the wars in Syria and Iraq go on for so long and doing so little to bring them to an end. The EU and Turkey both made critical mistakes, which could have been avoided, and neither have come up with realistic policies. Turkey was for long the sanctuary and transit point for the extreme Islamist armed opposition flooding into Syria. Erdogan and his government were convinced that President Bashar al-Assad's government was always on the verge of being overthrown though the evidence was much against this.