MUCH is unknown about the attempted military coup in Turkey on the night of July 15th.

Why was it botched so badly? How far up the ranks did the conspiracy reach? Were the putschists old-style secularists, as their initial communiqué suggested; or were they followers of an exiled Islamist cleric, Fethullah Gulen, as the government claims?

But two things are clear. First, the people of Turkey showed great bravery in coming out onto the streets to confront the soldiers; hundreds died. Opposition parties, no matter how much they may despise President Recep Tayyip Erdogan, united to denounce the assault on democracy. Better the flawed, Islamist-tinged strongman than the return of the generals for the fifth time since the 1960s.

The second, more alarming conclusion is that Mr Erdogan is fast destroying the very democracy that the people defended with their lives. He has declared a state of emergency that will last at least three months. About 6,000 soldiers have been arrested; thousands more policemen, prosecutors and judges have been sacked or suspended. So have academics, teachers and civil servants, though there is little sign they had anything to do with the coup. Secularists, Kurds and other minorities feel intimidated by Mr Erdogan’s loyalists on the streets.

The purge is so deep and so wide—affecting at least 60,000 people—that some compare it to America’s disastrous de-Baathification of Iraq. It goes far beyond the need to preserve the security of the state. Mr Erdogan conflates dissent with treachery; he is staging his own coup against Turkish pluralism. Unrestrained, he will lead his country to more conflict and chaos.

And that, in turn, poses a serious danger to Turkey’s neighbours, to Europe and to the West.

One more earthquake
 
The failed putsch may well become the third shock to Europe’s post-1989 order. Russia’s annexation of Crimea and invasion of eastern Ukraine in 2014 destroyed the idea that Europe’s borders were fixed and that the cold war was over. The Brexit referendum last month shattered the notion of ineluctable integration in the European Union. Now the coup attempt in Turkey, and the reaction to it, raise troubling questions about the reversibility of democracy within the Western world—which Turkey, though on its fringe, once seemed destined to join.

The turmoil is unsettling NATO, the military alliance that underpins Europe’s democracies.

Without evidence, Mr Erdogan’s ministers blame America for the coup; they have demanded that it extradite Mr Gulen, who lives in Pennsylvania, or risk Turkey turning its back on the West. Electricity to the military base at Incirlik, a hub of American-led air operations against Islamic State (IS), was cut off for a time. Were Turkey an applicant today, it would struggle to qualify for NATO; yet the alliance has no means to expel a member that goes bad.

With the second-largest armed forces in NATO, Turkey has been the forward bastion of the West, first against Soviet totalitarianism and then against the chaos of the Middle East. In the early years of government under Mr Erdogan’s Justice and Development (AK) party, the country became the model of a prospering, stable Muslim democracy. It sought peace with the Kurdish minority, and the economy grew healthily thanks to sensible reforms. The EU opened membership negotiations with Turkey in 2005.

But since major protests in 2013 against plans to build over Gezi Park in Istanbul, and then a corruption scandal, Mr Erdogan has become ever more autocratic. His regime has jailed journalists, eviscerated the army and cowed the judiciary, all in the name of rooting out the “parallel state” Mr Erdogan claims the Gulenists have built. As a cheerleader for the overthrow of Syria’s president, Bashar al-Assad, he turned a blind eye to the passage of jihadists through Turkey. Mr Erdogan wants a new constitution to allow himself to become an executive president, though he hardly lacks power.

He has abandoned all caution to achieve it, not least by letting peace talks with the Kurds break down. Turkey now faces a double insurgency: by the Kurds and the jihadists.

Autocrats R Us
 
Handled more wisely, the failure of the coup might have been the dying kick of Turkey’s militarists.

Mr Erdogan could have become the magnanimous unifier of a divided nation, unmuzzling the press, restarting peace talks with Kurds and building lasting, independent institutions. Instead he is falling into paranoid intolerance: more like the Arab despots he claims to despise than the democratic statesman he might have become.


 
Granted, the AK party has won every election since 2002. But Mr Erdogan’s view of democracy is distinctly majoritarian: though only about half of Turks vote for him, he thinks he can do what he wants. It will be principally for Turks themselves to check their president, by peacefully resisting his power grabs and backing his opponents at the ballot box.

Turkey’s Western friends must urge Mr Erdogan to exercise restraint and respect the law. But what if he will not listen? Turkey is a vital ally in the war against IS. It controls the south-eastern approaches to Europe, and therefore the flow of everything from natural gas to Syrian refugees. Europe cannot change geography, but it can make itself less vulnerable, starting with a proper system to control the EU’s external frontiers and handle asylum-seekers. And although Mr Erdogan holds many cards, he is not immune from pressure. Just before the coup he patched up relations with Israel and Russia.

Mr Erdogan’s greatest success—the economy—has become his weak point. Many tourists are now too frightened to visit, so the current-account deficit will only gape wider. To stay afloat the country needs foreign investment and loans, so it must reassure foreigners that it is stable.

With Mr Erdogan acting like a vengeful sultan, that will be hard.

The repercussions of the putsch will be felt for a long time. The coup-makers killed many fellow Turks, discredited the army, weakened its ability to protect the frontier and fight terrorists, rattled NATO and removed the restraints on an autocratic president. A terrible toll for a night of power-lust.