IN JUNE, a few months after Donald Trump, then a candidate for the Republican nomination, called for a ban on Muslim immigration, Turkey’s Islamist leader objected. President Recep Tayyip Erdogan demanded that Mr Trump’s name be removed from Trump Towers in Istanbul. “The ones who put that brand on their building should remove it immediately,” he said.

Mr Erdogan appears to have changed his mind, both about the towers and about the man whose name appears on them. Although polls show that most Turks would have preferred to see Hillary Clinton as America’s new president, Mr Trump’s election has been greeted in Ankara with a mix of schadenfreude and hope. “We were suffering from [American] policies towards the Middle East and Turkey under the Democrats and Obama,” says Yasin Aktay, a deputy chairman of the ruling Justice and Development (AK) party. “This opens a new page.” The Turkish president has been even more emphatic, calling protests against Mr Trump’s election in America and Europe “a disrespect to democracy”.

Flattery may have gotten Mr Trump somewhere: according to Diken, a Turkish news portal, he told Mr Erdogan over the phone that his daughter, Ivanka, admired him. In any case, Turkey is giving him the benefit of the doubt. For months, its government has pressed America to extradite Fethullah Gulen, a Pennsylvania-based preacher whom Turkey accuses of orchestrating a coup attempt in July that claimed some 270 lives. Turkish officials now believe Mr Trump will be more responsive to such exhortations than Mrs Clinton would have been. (Her campaign accepted donations from followers of Mr Gulen.) Mr Erdogan seems to think that the president-elect, a fellow populist who has expressed admiration for autocrats like Vladimir Putin, will look the other way as he locks up opponents and panders to his Islamist base.

He is not slowing down. Earlier this month AK tabled a bill pardoning statutory rapists who marry their victims, before shelving it following a popular outcry. Had it passed, the law would have allowed as many as 3,000 convicted sex offenders to walk free. That would have freed up room inside Turkey’s teeming prisons for some of the 37,000 people, including soldiers, bureaucrats, academics, journalists and a dozen Kurdish MPs, who have been arrested for political reasons since the July 15th coup. Over 120,000 others, including nearly 16,000 last week alone, have been sacked or suspended from office for alleged links to Mr Gulen or the outlawed Kurdistan Workers’ Party (PKK).

Mr Trump is expected to nag foreigners less about human rights than some American presidents have, though no one knows for sure. That would suit Turkey just fine. Mr Erdogan respects Western interests, but not Western norms. Last week he suggested that Turkey should join the Shanghai Cooperation Organisation, a Eurasian political, economic and military bloc that includes Uzbekistan, Russia and China, as an alternative to the European Union.

He may not be bluffing. Relations with the EU are worse than at any point since it accepted Turkey as a candidate for membership, almost two decades ago. Mr Erdogan has called for a referendum on ending Turkey’s application in 2017. He has proposed reinstating the death penalty, which would be incompatible with membership. And he has, ridiculously, accused the West as a whole of siding with Islamic State (IS). His foreign minister recently bragged about refusing to answer phone calls from his German counterpart.

The EU’s patience is starting to fray. Last week the European Parliament voted to recommend suspending Turkey’s accession talks. The vote is non-binding, and is unlikely to lead to anything: Germany fears that a snubbed Turkey might scrap its agreement to block human-smuggling across the Aegean Sea, allowing hundreds of thousands of migrants once again to flow into Greece. But with Europe’s populist parties growing stronger, and Mr Erdogan mobilising public opinion against the West, a showdown will be hard to avert.

If Turkey hopes to trade worsening relations with Europe for a new friendship with Mr Trump, it will be disappointed. The new president may be sympathetic to Turkish concerns about Mr Gulen, but then again he may not. And in any case, the cleric’s fate rests with America’s courts. Meanwhile, Mr Trump’s team wants to list the Muslim Brotherhood as a terror group, roll back the nuclear deal with Iran, and continue arming the PKK’s Syrian wing against IS. Mr Erdogan opposes all these measures vehemently.

Moreover, the officials named so far to the incoming administration are no great fans of Mr Erdogan. Michael Flynn, Mr Trump’s pick for national security adviser, penned an op-ed this month praising Turkey as “a source of stability”, but Turkish officials were troubled to find that a video shot on the night of the coup shows Mr Flynn cheering on the mutinous generals against Mr Erdogan’s government. In a tweet posted on the same date, Mr Trump’s choice for the head of the CIA, Mike Pompeo, called Turkey an “Islamist dictatorship”. Some in Ankara are already growing disillusioned. “This sounds like a crusader discourse,” says Mr Aktay. The relationship between Mr Erdogan and Mr Trump has gotten off to a good start. It may not last.