By Seda Sezer and Tuvan Gumrukcu

ISTANBUL (Reuters) - Turkey on Tuesday warned of rising anti-American sentiment and risks to a migrant deal with the European Union, ramping up the rhetoric in the face of Western alarm over the scale of purges in state institutions since last month's failed coup.

President Tayyip Erdogan, who was in Russia on Tuesday for talks with Vladimir Putin on improving ties, has sharply criticized the United States and the EU for what he says is a lack of solidarity with Turkey over the July 15 coup and of caring more for the rights of the suspected plotters.

Erdogan blames Fethullah Gulen, a Muslim cleric who has lived in self-imposed exile in the U.S. state of Pennsylvania since 1999, and his followers for the attempted putsch, in which more than 240 people were killed and nearly 2,200 wounded.

Turkey has launched a series of mass purges of suspected Gulen supporters in its armed forces, other state institutions, universities, schools and the media since the abortive coup, prompting Western worries for the stability of a key NATO ally.

Justice Minister Bekir Bozdag said anti-American feeling among Turks was on the rise and could only be calmed by the United States extraditing Gulen, who denies any involvement in the coup and has condemned it.

"There is a serious anti-American feeling in Turkey, and this is turning into hatred," Bozdag said in an interview with state-run Anadolu Agency, broadcast live on Turkish television channels. "It is in the hands of the United States to stop this anti-American feeling leading to hatred."

Responding to Turkey's demand for Gulen's extradition, U.S. President Barack Obama has said Ankara must first provide clear evidence of wrongdoing. Last week a State Department spokesman said Washington was evaluating new documents it had received.

"Whether the U.S. extradites Gulen or not this will be a political decision," Bozdag said. "If he is not extradited, Turkey will have been sacrificed for a terrorist."

EU STRAINS

Turkey's relations with the EU, which it hopes to join, have also come under heavy pressure since the abortive coup and on Tuesday Denmark's government party said Ankara's accession talks should end due to what it called Erdogan's "undemocratic initiatives" and his support for reintroducing the death penalty.

Erdogan has said he would approve the return of capital punishment if Turkey's parliament backed it.

On Sunday Austria's foreign minister threatened to block EU negotiations with Turkey. But Germany, the EU's most powerful member, has dismissed such demands, stressing Turkey's geopolitical, economic and military importance.

Turkey's EU Affairs Minister Omer Celik said on Tuesday Ankara would stop implementing a deal with Brussels to stem the flow of migrants into the EU if the bloc does not provide a clear date to grant visa-free travel to Turks visiting Europe.

In an interview with Haberturk television, Celik said asking Turkey to change its terrorism laws, a key demand from the EU to finalize the visa-free travel, would mean endangering Europe's own security. He gave no details.

Though criticized by rights advocates, the EU's deal with Turkey has helped to sharply cut the number of refugees and migrants reaching European shores, giving EU politicians breathing space after around 1.3 million people reached the continent last year.

In contrast to the chill in Turkey's ties with the West, a Turkish official described the mood at Erdogan's talks in St Petersburg with President Putin on Tuesday as "very positive".

Putin said he hoped Erdogan would be able to restore order in Turkey after the coup and stressed his wish to restore good bilateral relations, which were harmed by Turkey's downing of a Russian fighter jet near the Syrian border last November.

Erdogan hailed the start of "a very different period" in relations between Turkey and Russia, historic foes which have nevertheless built strong trade, energy and tourism ties in the post-Soviet era.

However, Turkish officials have said Erdogan's visit to Russia is not intended to signal a fundamental shift in Ankara's geopolitical stance.

Turkey hosts American troops and warplanes at its Incirlik Air Base, an important staging area for the U.S.-led fight against Islamic State militants in neighboring Iraq and Syria.

PURGES

A recent opinion poll showed two thirds of Turks agree with their president that Gulen was behind the coup plot. Turkey has been holding almost daily mass rallies since July 15 in support of democracy and the government and against the plotters.

The 75-year-old Gulen built up a network of schools, charities and businesses in Turkey and abroad over decades. He has accused Erdogan of using the coup to amass greater power, echoing concerns expressed in some Western capitals.

Turkish Prime Minister Binali Yildirim on Tuesday repeated a pledge to bring Gulen back to Turkey.

"That terrorist leader will come to Turkey and pay for what he did," Yildirim told a meeting of his ruling Islamist-rooted AK Party in parliament. "That religious, impudent, lying, bloody murdering nothing will be surely held accountable."

Authorities have suspended, detained or put under investigation tens of thousands of people in the armed forces, the judiciary, civil service and elsewhere since the coup, in which a faction of the military commandeered warplanes, helicopters and tanks in an attempt to topple the government.

On Tuesday Bozdag put the number of people now formally arrested awaiting trial at 16,000, adding that a further 6,000 detainees were still being processed. Another 7,668 people are under investigation but have not been detained, he said.

Since the abortive putsch, pro-government papers have been awash with conspiracy theories accusing the United States and the CIA of being the masterminds. Turkish officials privately said such reports do not reflect Ankara's formal stance.

Turkish authorities have said the country's intelligence service has cracked into several smartphone messaging apps that Gulen's followers used to communicate with each other in the years ahead of the coup attempt and was able to trace tens of thousands of people from the group.

A senior Turkish official said Turkey's intelligence agency had identified at least 56,000 operatives of Gulen's network after it cracked a little-known smartphone messaging app called ByLock, which the group had begun using in 2014. By this year, Turkish intelligence were able to map their network.

"Our assessment is that 150,000 unique operatives used ByLock to communicate with others," the official said.

(Additional repporting by Daren Butler and Gulsen Solaker in Ankara; Writing Humeyra Pamuk; Editing by Patrick Markey and Gareth Jones)