ATHENS, Greece (AP) — It had been billed as a state visit that would patch up frayed ties between two NATO allies and potentially serve as a platform for Turkey to make overtures toward Europe after months of strained relations.

Instead, Turkish President Recep Tayyip Erdogan had barely landed in Athens earlier this month before he rattled his Greek hosts by addressing a series of disputes, and calling into question a crucial treaty that delineates the two countries' borders and sets the status of their minorities.

His confrontational stance was one Erdogan's Western allies have become increasingly familiar with, as Turkey's president goes his own way, unfettered by collective goals and seeking to promote his country as a force to be reckoned with.

"Turkey is trying to detach itself from the West, to show that it is a player on the regional but also international stage, which has its own positions, its own interests, which are not necessarily in line ... with those of the West," said Constantinos Filis, research director of the Athens-based Institute of International Relations. Erdogan, he said, aimed to make his country into a great regional, military and economic power "whose interests are respected by all."

Over the past year and a half, particularly since his government survived an attempted coup in July 2016, Turkey's ties with several European countries and with the European Union in general have become increasingly strained.

Erdogan, never one to shy away from a verbal spat, launched a series of insults at his allies, accusing European officials of racism, harboring terrorists, and behaving like Nazis. Ankara's decades-long efforts to join the EU, which have appeared moribund for years, seemed to inch even further away.

Outspoken quips are nothing new for Erdogan, who has governed Turkey since 2003, first as prime minister until 2014 and thereafter as president.

"If he wants to start a discussion on a topic that he finds attractive, he goes to the public and shocks the public," said Behlul Ozkan, associate professor at Marmara University's department of international relations. "He did that so many times in the last 15 years. And he's been doing (it) in diplomacy in the last couple of years."

The rhetoric plays well domestically, with many Turks seeing their president as a champion of national pride and of the Muslim world.

According to a public opinion survey on foreign policy by Turkey's private Kadir Has University conducted in June, 38.5 percent of Turks believe Turkish foreign policy is successful — a 4.5 percentage point increase from last year. The countries the respondents identified as being the biggest threat to Turkey were the United States, Israel and the EU. The study was conducted June 6-30, speaking with 1,000 people in 26 Turkish cities.

"I think he's better than previous leaders, at least with Muslim countries," Yilmaz Demiroz, a 48-year-old landscape gardener in Istanbul, said of Erdogan. "He has the clearest stance from all the leaders I've seen."

For their part, Europeans have been aghast at the results of Erdogan's crackdown after the attempted coup, which has seen 110,000 people fired from their jobs, and about 50,000 more jailed on suspicion of even the most tenuous of links to Fethullah Gulen, the US-based Islamic cleric Erdogan blames for the putsch.

Turkey's relations with the US have fared even worse, fueled by accusations from Ankara that Washington is seeking to deliberately undermine it, both by harboring Gulen and due to an ongoing New York trial of a Turkish banker over alleged transactions with Iran that threatens to implicate Erdogan's government. How US-Turkish ties will develop is unclear, analysts say.

"The relationship between Turkey and the United States can go in a very negative direction and there can be very negative consequences, both for Turkey and the United States," said Ozkan. "It's really very, very difficult to predict right now."

As relations have cooled with the EU and Washington, they have seemed to warm with Moscow and Tehran. Erdogan and Russian President Vladimir Putin have met several times so far this year, and Tukey recently signed a deal to purchase Russian S-400 missiles. The move horrified NATO, of which Turkey has been a member since 1952.

"Turkey is following a brinkmanship policy. It is moving on a razor's edge," said Filis, noting Turkey's rapprochement with Russia and Iran were distancing it from the West. Such policies, he said, "create in the West a problem of conscience regarding how to handle Turkey."

But analysts stress that fears Russia or Iran could entirely replace the West in Turkey's relations are premature, particularly given the EU's role as Turkey's main trade partner and investor.

"Russia can only play a supplementary role with regard to Turkey's economy," said Filis. "Although Erdogan finds it easier to communicate with Putin, because they're both authoritarian, I don't think that in the long term Russia can replace the West in terms of security and in terms of the economy."

Ozkan shared the view, nothing that with Turkey drifting toward authoritarianism, Erdogan was trying to redefine relations that limit liberal, outside influences and increase his negotiating power.

"There have been lots of reports about Turkey leaving the West and making an alliance with Russia. And I don't think this reflects reality," he said. "I don't think that President Erdogan wants Turkey to leave the western camp. .... (the) Turkish economy simply cannot survive without western investment. And Russia doesn't have that financial power."

It is in Europe's interests, too, to keep Turkey close. Apart from its potential economic might, its strategic geographical position straddling Europe and Asia and abutting the Middle East makes it a crucial partner. For one, Turkey absorbed the vast majority of refugees who fled from Syria. Even though nearly three times as many remained in Turkey as those who made it the EU, the refugee crisis put a tremendous strain on Europe, which saw relations between its own members fray over the issue.

"Is Europe going to accept Erdogan as he is, or is Europe going to force him to change, according to European standards?" questioned Ozkan. "That's the biggest issue."

____

Zeynep Bilginsoy in Istanbul contributed to this report.