By Nick Tattersall and Paul Taylor
ISTANBUL/BRUSSELS (Reuters) - Britain's Brexit campaign and the rise of Europe's populist right have further dented Turkish hopes of ever joining the EU, leaving President Tayyip Erdogan largely indifferent to its criticism and weakening an anchor of Turkish reform.
While neither side has any interest in ending Turkey's decade-long accession process, their relations are increasingly transactional, driven by mutual need in areas such as migration, trade and security, rather than by convergence towards European Union norms on democracy and basic rights.
Warnings from populist leaders around Europe of creeping Islamization and from campaigners for a British exit from the EU of dire consequences if Turkey, a Muslim nation of 78 million, ever joins, have led Turkish leaders to complain increasingly openly about what they see as European Islamophobia.
"Europe, you don't want us because the majority of our population are Muslim ... We knew it but we tried to show our sincerity," Erdogan said at a graduation ceremony in Istanbul on Wednesday, the eve of Britain's "Brexit" vote, quipping that Turkey too could hold such a referendum.
"We will go and ask the public whether we should continue negotiations with the EU," he said.
Turkey has so far lived up to its side of a landmark deal with Brussels to stop illegal migration to Europe via its shores, in return for financial aid, the promise of visa-free travel to much of the bloc and accelerated talks on membership.
But it has alarmed EU leaders by pressing ahead with a crackdown on Erdogan's opponents, including moves to prosecute pro-Kurdish opposition politicians on terrorism charges, the detention of journalists and academics, and changes in the judiciary seen by critics as a purge of dissident judges.
"The EU-Turkey deal (on migration) is holding and there's no reason to fear it won't hold, despite the public bluster," a senior EU source told Reuters, pointing out that the numbers of illegal migrants crossing from Turkey had dropped sharply.
"But there are grounds to be quite worried about Turkey's overall direction of travel," the source said, pointing to the plans to remove hundreds of judges and to the recent lifting of immunity for members of parliament, a step toward the prosecution of opposition deputies.
Turkey has so far refused to back down on a key sticking point in the bid to secure visa-free travel to Europe's 26-nation Schengen area, namely EU demands that it change sweeping anti-terrorism laws used against intellectuals, Kurdish sympathizers and Erdogan's critics.
That risks further antagonizing a skeptical European Parliament, the EU's most vocal institution on human rights and freedom, which has to approve visa liberalization.
Turkey says the anti-terror laws are crucial when an insurgency by militants in its largely Kurdish southeast is at its most violent since the 1990s, and when it faces a growing threat from Islamic State fighters from neighboring Syria.
"A change of attitude is out of the question," Yasin Aktay, deputy chairman of the ruling AK Party, told Reuters.
But officials on both sides are hoping for a compromise.
Some EU leaders, notably Donald Tusk, the former Polish premier who chairs EU summits and was involved in negotiating the migrant deal with Erdogan, argue that Turkey should not get all the credit for the decline in migrant arrivals.
Tightening borders and sealing off Greece from the rest of Europe had delivered a drop before the deal with Ankara was signed, an EU official said, suggesting Turkey was not in as strong a negotiating position as it might think.
"We feel that we have the leverage. We are not solely in the hands of Turkey," the official said.
Brussels aides also note that Ankara's ties with Russia, the United States, Syria, Iran and Israel are all strained, hence it needs better relations with the EU.
European Commission President Jean-Claude Juncker said last month Erdogan should "think twice" before refusing to change the anti-terrorism laws and warned he would "have to explain to the Turkish people why he is responsible for them not getting the right to travel freely in Europe".
The combative Turkish leader, well used to demonizing the EU to his loyal supporters, is seeking popular backing to change the constitution and boost his powers. He is counting on the support of nationalists more interested in seeing him take a hard line on Kurdish militants than kowtow to Brussels.
"Fundamentally, Erdogan may have calculated that as much as visa freedom would be a positive development, it is not enough of a benefit for him to be seen to be soft on terror," said Sinan Ulgen, chairman of Istanbul-based think tank EDAM.
Such political calculation will increasingly lie at the heart of Turkey's dealings with the EU, Ulgen said, predicting Ankara would cooperate with Brussels only in areas where it saw a clear strategic interest.
"For all practical purposes the accession dynamic is dead ... In a way it has become inconsequential as far as Erdogan is concerned," said Ulgen, a visiting scholar at Carnegie Europe and a former diplomat in Turkey's EU delegation.
"It will be a piecemeal effort to concoct areas of common interest and build structures of cooperation as the need arises ... That has been the case for refugees, that will be the case for economic integration, possibly for cooperation on counter-terrorism, and areas like that."
Turkey will take a modest step forward in the accession process on June 30 when it opens a new chapter of negotiations with the EU on budget policy.
EU officials say the European Commission will adopt a draft negotiating mandate in October or November to widen a 20-year customs union with Ankara, a bigger potential prize which they believe reformist parts of the government are determined to secure and which they hope will give Brussels extra leverage.
Deputy Prime Minister Mehmet Simsek, seen as one of few reformers in a new government dominated by allies of Erdogan, told Reuters last week that such a deal to extend the union to cover services, agriculture and public procurement could make Turkey the bloc's third largest trade partner.
But he said Turkey's influence in the Middle East, its role as an energy hub and its importance as an intelligence partner meant relations with Europe were not a one-way street.
"Europe needs Turkey if it wants to have a stronger say in international affairs in this geography, if it wants energy supply security, if it wants even overall security," he said.
"It is in our interests to remain anchored to Europe, and it is in Europe’s interests to keep Turkey firmly anchored to Europe."
(Additional reporting by Ercan Gurses in Ankara, Alastair Macdonald in Brussels; Writing by Nick Tattersall; editing by Philippa Fletcher)