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 (see article here and here). 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.