The failed military coup is a disaster for Turkey, but its success would have been a far greater calamity. If the plotters had killed or captured President Recep Tayyip Erdogan then other parts of the armed forces might have joined them, but a civil war would have been inevitable as the security forces split and Erdogan’s supporters fought back.

The disaster is that it will now be much more difficult for Turks to resist Erdogan establishing a monopoly of power. By resisting the coup as the leader of a democratically-elected government, he has enhanced his legitimacy. Moreover, all opposition to his rule can be labelled as support for terrorism and punished as such.

“Human rights and democracy will be weaker and they were already in a bad way before the coup,” says a critic of Erdogan, who does not want his name published, adding that it is difficult for him to criticise Erdogan today while he is under threat from military conspirators. He has no doubt that the attempted putsch was carried out by the followers of Fethullah Gulen, who has lived in the US since 1999. Leaving aside the confessions of the plotters, which may have been forced, only the Gulenists had a network of adherents capable of staging an uprising in so many units of the security forces.

“Fethullah did not help us, he killed us,” says the Turkish commentator bitterly. “He left us totally in the hands of Erdogan.”

He says that the Gulenists operate in two different ways: they have a moderate public face with schools, universities, media and business associations, but they also have always had a secret organisation devoted to taking positions of power within the military, police and security services. As long ago as 1987, the movement was being investigated for infiltrating military colleges. It is now being compared to the Roman Catholic organisation Opus Dei, notorious for its links to Franco and other right wing governments, though a better analogy might be a secretive cult with a charismatic leader.

In pictures: Turkey coup attempt Show all 17 1 /17 In pictures: Turkey coup attempt In pictures: Turkey coup attempt Turkish President Erdogan attends the funeral service for victims of the thwarted coup in Istanbul at Fatih mosque on July 17, 2016 in Istanbul, Turkey Burak Kara/Getty Images In pictures: Turkey coup attempt Soldiers involved in the coup attempt surrender on Bosphorus bridge with their hands raised in Istanbul on 16 July, 2016 Gokhan Tan/Getty In pictures: Turkey coup attempt A civilian beats a soldier after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 REUTERS/Murad Sezer In pictures: Turkey coup attempt Surrendered Turkish soldiers who were involved in the coup are beaten by a civilian Reuters In pictures: Turkey coup attempt Soliders involved in the coup attempt surrender on Bosphorus bridge Getty In pictures: Turkey coup attempt Supporters of Turkish President Recep Tayyip Erdogan wave flags as they capture a Turkish Army vehicle Getty In pictures: Turkey coup attempt People pose near a tank after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 Reuters In pictures: Turkey coup attempt Turkish soldiers block Istanbul's Bosphorus Brigde Getty In pictures: Turkey coup attempt A Turkish military stands guard near the Taksim Square in Istanbul Reuters In pictures: Turkey coup attempt Pierre Crom/Twitter In pictures: Turkey coup attempt Turkish soldiers secure the area as supporters of Recep Tayyip Erdogan protest in Istanbul's Taksim square AP In pictures: Turkey coup attempt People demonstrate in front of the Republic Monument at the Taksim Square in Istanbul Murad Sezer/Reuters In pictures: Turkey coup attempt Turkish soldiers detain police officers during a security shutdown of the Bosphorus Bridge Reuters In pictures: Turkey coup attempt Turkish Army armoured personnel carriers in the main streets of Istanbul Getty In pictures: Turkey coup attempt Chaos reigned in Istanbul as tanks drove through the streets EPA/TOLGA BOZOGLU In pictures: Turkey coup attempt Turkish President Tayyip Erdogan speaks to media in the resort town of Marmaris Reuters In pictures: Turkey coup attempt Supporters of President Erdogan celebrate in Ankara following the suppression of the attempted coup Reuters

The coup went off half-cock. It was staged prematurely because of fear of an imminent purge of Gulenists in the military. Analysts have been explaining how badly organised the attempt was and how it could never have succeeded.

But the initial response of the government to the putsch was equally cack-handed, with Erdogan saying that he first heard something was amiss from his brother-in-law who phoned him between 4 and 4.30pm on 15 July to say that soldiers were stopping cars next to the Beylerbeyi Palace in Istanbul.

Erdogan’s account of what happened next is worth quoting in order to convey the atmosphere of confusion in the first hours of the abortive takeover.

He says that his brother-in-law “was telling me that soldiers were actually cutting off streets, and they were not allowing cars to proceed to take to the bridge. When I got the news, initially I did not believe that this was happening and I called the head of national security, the head of national intelligence, I could not reach him. I called the chief of staff of the armed forces, I could not reach him, they were not in a position to be able to answer their phones... Then I tried to contact the prime minister, and although with some difficulty, we were able to get into contact.”

It was only almost four hours later, at 8 pm, that Erdogan made plans to act by contacting the media – quite long enough for the pro-coup forces to have eliminated him. If victory goes to the side that makes the least mistakes, then it was a close run thing.

Aside from their organisational failings, the plotters made a miscalculation in imagining that, because Turks are deeply divided between supporters and opponents of Erdogan, the latter night side with anybody trying to get rid of him by physical force.

In the event, the plotters found no support because people felt, as one Kurdish activist was quoted as saying, that “the worst politician is better than the best general.”

Much now depends on the extent to which Erdogan sees the failure of the coup as a heaven-sent excuse to remove all who do not obey him. The temptation is clearly there: some 60,000 soldiers, judges, prosecutors, civil servants and teachers have been detained, arrested or sacked.

All 3.3m civil servants in Turkey have been told to stay in their jobs, presumably so they can be investigated. The crackdown under the State of Emergency appears to be spreading well beyond the circle of those implicated in the coup or connected to the Gulenists.

Overreaction by the state may be deliberately contrived in order to benefit from the crisis, but there is also real fear mixed with paranoia that the coup is not entirely over.

Supporters of the Government tweeted yesterday that there might be a second attempt and some military units have been confined to their bases. Meanwhile the coup is being presented as a symbol of evil as was Guy Fawkes and the Gunpowder Plot of 1605 in English political tradition. Public demonstrations of anti-coup feeling are being demanded by the state, with people asked to attend daily demonstrations and actors in Istanbul being asked to produce an anti-coup video.

The next few weeks will tell if Erdogan is going target all dissent and further divide a deeply divided country. He may have a difficulty in pursuing the war against Kurdish guerrillas in south-east Turkey and, at the same time, purging the Second Army that is meant to be fighting them and whose commanding general is under arrest. It might be sensible to conciliate the Kurds, with whom Erdogan was negotiating not so long ago, but his combative political instincts are more likely to lead him to opt for continuing confrontation.

Turkey failed coup attempt: How it unfolded

Islamic State will benefit from the new political landscape because security forces will be tracking Gulenist sleepers rather than Isis cells. Isis will gain from the anti-American mood in Turkey post-coup because the Government and much of the population are convinced that the US was implicated in the attempt. Whatever happens to the Turkish demand that the US hand over Gulen, Turks are convinced of a US role, citing as evidence Mr Gulen’s long presence outside Philadelphia. Isis will seek the support of a widening anti-US constituency in Turkey. Relations between Ankara and Washington were not good before; they are about to get worse.

Erdogan emerges politically stronger from the crisis, but he rules a weakened Turkish state. The army and state institutions are being hollowed out by purges and loyalty, not competence, becomes the test for advancement. Turkish involvement in Syria has produced only failure: sectarian and ethnic warfare between Sunni and Shia, Kurd and non-Kurd is infecting Turkey.