By Patrick Markey
ISTANBUL (Reuters) - The last time U.S. Vice President Joe Biden flew to Turkey, in January, he had a stern message for President Tayyip Erdogan: his model of Islamic democracy was setting a bad example by intimidating media and threatening academics.
But his tone was markedly different when he arrived in Ankara on Wednesday, weeks after a failed coup in Turkey that has strained relations between the two countries, and he appeared to be in diplomatic damage-limitation mode.
Turkish officials have been incensed by the concerns expressed by Washington and European capitals about Ankara's subsequent crackdown on suspected plotters, but what they perceive as indifference to the coup attempt itself.
A weakening of the U.S.-Turkish alliance is a concern for the United States, which is counting on support from Turkey - which has NATO's second-biggest military - in the battle against Islamic State.
American worries may have been compounded by Erdogan restoring ties with Russia and even discussing military cooperation with President Vladimir Putin.
Meeting with Erdogan and Turkey's prime minister in Ankara on Wednesday, Biden delivered a message of alliance and conciliation.
"Let me say it for one last time: The American people stand with you ... Barack Obama was one of the first people you called. But I do apologize. I wish I could have been here earlier," Biden said.
He said U.S. officials would cooperate in investigating evidence against Fethullah Gulen, the U.S.-based cleric Erdogan has blamed for masterminding the coup bid with his followers.
Erdogan has demanded that Washington hand over Gulen, who has denied any involvement in the coup, but U.S. authorities have said Turkey must first provide evidence of his wrongdoing.
Hours before Biden arrived, in a timely illustration of the role Turkey plays in the fight against Islamic State, Turkish forces backed by U.S.-led coalition jets launched a major push across the border into northern Syria to drive the jihadist group out of the frontier town of Jarablus.
Former Supreme Allied Commander at NATO, Admiral James Stavridis, said the key to U.S. ties with Turkey was balancing realist and idealist tensions, between the need for a strong, regional NATO ally and drawing attention to human rights.
"The vice president's visit is an effort to find the right setting on the dial, and will somewhat disappoint those who want a more black-and-white stance on human rights," said Stavridis, now dean at the Fletcher School of Law and Diplomacy at Tufts.
"But given the huge geopolitical issues at play, my sense is he hit the right notes."
Since the attempted coup - in which more than 240 people were killed - Turkish authorities have dismissed or suspended tens of thousands of military personnel, civil servants and judges suspected of ties to Gulen's network. Around 40,000 people have been formally arrested for links to the coup.
Turkey's ties with the European Union have also been strained by the reaction to the government crackdown. EU officials, like Washington, have expressed concerns about the scale of the purge and urged Ankara to uphold the rule of law.
The rift has increased tensions over an EU deal with Turkey to help tackle Europe's migrant crisis - the other powerful piece of leverage Erdogan holds with the West.
Ankara has warned that Turkey could walk away from its promise to stem the flow of illegal migrants to Europe if the European Union fails to grant Turks visa-free travel in October.
European officials have in the past often chided Erdogan for what his opponents say is creeping authoritarianism and an intolerance of dissent, including the jailing of critical journalists - charges denied by the Turkish leader.
But those who have visited Turkey over the past two weeks have, like Biden, taken a more conciliatory tone.
Even before the diplomatic tensions in the aftermath of the coup, U.S.-Turkish relations were complex and sensitive.
The two NATO members work together against Islamic State in Syria. However Turkey backs Syrian rebels in a drive to oust the jihadist group, but also to halt the advance of a U.S.-backed force of mainly Kurdish fighters who Ankara views as allies of Kurdish insurgents on its own soil.
The dual nature of Turkey's security concerns in neighboring Syria was underlined by its U.S.-backed incursion this week, which it said was as much about stopping Kurdish militia seizing territory as it was about eliminating Islamic State.
One U.S. official said Biden's trip was in part to correct the impression among some Turks that Washington somehow endorsed the attempted coup, and also make clear the U.S. government understands the trauma of the putsch for Turkey.
"The vice president's empathy was genuine and important for the people of Turkey to hear. At a time of great uncertainty, it is important to remind friends you have their back," said the official, who spoke on condition of anonymity.
Biden visited the parliament building in Ankara bombed during the coup by rogue pilots in commandeered jets, expressing dismay at the loss of life.
Erdogan acknowledged the importance of the alliance between Turkey and the United States and welcomed Biden's message of solidarity. But he dismissed the vice-president's comments that a U.S. federal court must decide whether Gulen should be sent to Turkey, instead demanding the cleric be handed over immediately.
"What an opportunity he and the U.S. administration wasted," Daily Sabah, pro-government newspaper wrote in an editorial this week. "Did he take this long trip to Turkey merely to say 'It's in the hand of the courts'? Couldn't a simple intern in his office have conveyed the same message without creating all this fuss?"
(Additional reporting by Jeff Mason and Cagan Uslu; Editing by Nick Tattersall and Pravin Char)