The kneejerk response of Turkey’s leaders to the country’s latest terrorist atrocity – Sunday’s suicide bombing in Ankara that killed 37 people and injured more than 100 – suggests that Recep Tayyip Erdoğan, Turkey’s strongman president, and his neo-Islamist party are fresh out of ideas about how to halt what looks increasingly like a slide into chaos.

The bigger problem, for Turkey’s US and European allies, is how to shore up a strategically important Muslim democracy, Nato member and EU applicant that had long been considered a vital outpost of stability in a volatile region. Once-dependable Turkey seems in danger of implosion. Under Erdoğan, Turkey is the west’s disintegrating ally and Europe’s imaginary friend.

This dilemma will come sharply to a head later this week when Angela Merkel, Germany’s chancellor, tries finally to seal an EU deal with Turkey on Syrian migrants. Erdoğan is demanding visa-free travel for Turks, accelerated accession talks and for Brussels to ignore human rights abuses in return for his cooperation. Several EU countries, notably France and Cyprus, are adamantly opposed.

Erdoğan set Sunday’s bombing, the second in Ankara in two months, in his preferred narrative context: as part of a life-or-death national struggle against shadowy forces bent on victimising and destroying Turkey. This is the only tune on his playlist. He uses its fearful message to win elections, rally nationalists and delegitimise opponents.

“Our state will never give up using its right of self-defence in the face of all kinds of terror threats. All of our security forces, with its soldiers, police and village guards, have been conducting a determined struggle against terror organisations at the cost of their lives,” Erdoğan said, ignoring the fact that Sunday’s victims were civilians.

Officials pinned the blame, predictably, on Erdoğan’s bête noire, the Kurdistan Workers party (PKK), although a more likely culprit is an extremist splinter group, the Kurdistan Freedom Hawks, which perpetrated the 17 February Ankara attack. When the capital was bombed last year, the Kurds were again initially blamed. It later transpired that Islamic State was responsible.

Following his usual script, Erdoğan authorised retaliatory airstrikes on Monday on PKK targets in northern Iraq, another example of how the Turkish leader lashes out under pressure. It is a dangerous reflex. Last year, Erdoğan ordered the shooting down of a Russian warplane that briefly entered Turkish airspace from Syria. Bilateral relations have been dreadful ever since.

Security forces also intensified operations in ethnic Kurdish areas of southern and south-eastern Turkey that have killed hundreds of people and displaced tens of thousands since last year. Curfews and martial law, backed up by tanks, were imposed on Monday on Yüksekova and Şırnak, near the Iraq border, and Nusaybin, close to Syria.

Turkey’s internal Kurdish problem is only one of the challenges that Erdoğan’s confrontational approach appears to exacerbate. Turkey is at war, on and off, with Syrian Kurdish militias fighting Isis in northern Syria. Ankara fears they may try to create a separate political entity linked to the autonomous Kurdish region in northern Iraq and even Turkey itself.

Signs of societal disintegration may also be seen in Erdoğan’s manipulation of the judiciary, repeated threats to prosecute pro-Kurdish MPs and politicians, curbs on media freedom and independent journalism, unchecked corruption, and his attempt to enact a new constitution giving him Vladimir Putin-style presidential powers. He is obsessed with a supposed “parallel state” conspiracy against him allegedly led by an exiled former ally, Fethullah Gülen, and has ordered mass arrests.

At the weekend, the main opposition Republican People’s party leader, Kemal Kılıçdaroğlu, said Erdoğan’s ruling Justice and Development party (AKP) would stop at nothing to stay in power. “Turkey is step by step sliding towards an authoritarian regime … The AKP is currently in a position that it may do everything not to leave power, including [committing] political murder,” he said.

Erdoğan’s for-me-or-against-me stance increasingly pits Turkey against longtime allies. The migrant deal, which the UN and aid agencies say is probably illegal, is just the latest flashpoint. Last autumn, when visiting Brussels, he angrily threatened to flood Europe with refugees unless the EU bowed to his cash demands. He often mocks and berates the EU, once calling it an elitist, Islamophobic Christian club. He flatly rejects European criticism of increasingly worrying media controls and human rights abuses.

Erdoğan has also fallen foul of the Obama administration over how best to fight Isis and his cross-border shelling of Syrian Kurdish militias, who Washington regards as useful allies against the jihadis and the Damascus regime. In a recent interview, Barack Obama described Erdoğan as a failure and an authoritarian. When Turkey shot down the Russian warplane, the US was almost as alarmed as Moscow, especially when Erdoğan called for Nato backup.

In Ahmet Davutoğlu, Turkey’s prime minister, the west has a thoughtful interlocutor who will try his best to cut a deal on migrants and refugees with the EU this week. But Davutoğlu, a former academic who owes his political career to Erdoğan’s patronage, does not call the shots. Turkey’s irascible, unbiddable president does – and in his hands lies Turkey’s future as a dependable partner.