Although coups and the Turkish military used to be synonymous, this weekend's attempted coup, while disturbing, was in the end not a very well executed one.

The plan was launched after working hours and while President Recep Erdogan was on holidays, which showed a sense of timing. Apart from this though, it was littered with fundamental errors. To begin with, when you are committing regicide, the first target has to be the regent. Erdogan may have been isolated for a short period of time but he wasn't detained or otherwise neutralised. Coup plotters only have the element of surprise for a short period of time. They have to create the impression the coup is a fait accompli and they are firmly in control in order to maintain momentum and quickly win over those outside the secret planning bubble that has existed up until the coup commences. This didn't happen. The plotters also failed to control all the means of communication (a difficulty in contemporary coups given the plethora of media platforms and broadcasters), and had insufficient ground troops to conduct the tasks a successful coup requires.

While Erdogan's sense of mission has led him to make significant foreign policy mistakes and alienate many leaders in the region and the West, domestically he maintains a large and well-organised support base. By failing to silence him, the coup plotters allowed Erdogan to quickly mobilise his national support base in the Justice and Development Party (AKP) that he helped to found.

There were reports that the mosques used their public address systems to sound the call to prayer and to get people out on the streets to protest against the coup. All imams are appointed and paid for by the Religious Affairs Department and very much owe their allegiance to the Islamist AKP. Once the pro-government supporters were mobilised, the insufficiency of the forces at the coup-plotters' disposal became readily apparent. It didn't last much past daybreak.

In response Erdogan has moved more quickly and ruthlessly than the coup plotters did.

Thousands of members of the military and judiciary have been detained and responsibility for the coup has been sheeted home to supporters of Erdogan's former ally but now foe, Fetullah Gulen, resident in the United States. On what evidence this is based is unclear and the Gulenists have vehemently denied any involvement. For Erdogan though they are handy scapegoats whether the claim is true or not. It means he can not only portray the group, that also claims religious legitimacy through a more secular Islamic outlook, as being a threat to national security, but can also implicitly implicate Washington by decrying its refusal to extradite Gulen to Turkey.

This approach also means that he doesn't have to acknowledge any domestic sources of discontent against his rule, while at the same time allowing him to quarantine the bulk of the military from public criticism. Erdogan needs the military now more than ever as an effective force as he has security issues on the border with Syria and is fighting a semi-conventional war in the country's southeast against Kurdish groups.

The sources of discontent

For all of the president's domestic strength and authority however, there is no getting away from the fact there is discontent. Parts of the military and other sections of society are unhappy with Erdogan's aggregation of power at the expense of democratic checks and balances, including an independent judiciary and free press. Erdogan's foreign policy errors in Syria and poor relations with Russia after the downing of a Russian aircraft, along with suspicion from Egypt and many of the Gulf states at his links with the Muslim Brotherhood, have impacted on Turkey domestically. Islamic State has conducted attacks against Turkey with a focus on tourist infrastructure. This, along with the Russian economic sanctions, has made a difficult economic picture in Turkey even worse.

His domestic opponents will not have welcomed the attempt by the military faction to overthrow the democratically elected government (and kill more than 200 people in the process), regardless of how authoritarian that government has become. But the fact that a coup attempt was made points to the magnitude of the fissures in Turkish society. The coup plotters claimed to be acting to restore democracy without a hint of irony. However, they also pointed to the need to stem corruption and the move away from secularism, both claims that resonate with a significant element of the Turkish population.

To many leaders, an attempted coup would give one pause for thought as to the direction they had taken a society. But Erdogan cares little for introspection and is driven to a large extent by ideology. He has made his way in the hard scrabble of Turkish politics with a firm belief in using power to shape society, and the fewer constraints on that power the better. He is little interested in repairing fissures in society, rather he is focused on punishing those who were directly involved in the coup and in purging those who may support opposing views to that of the AKP. He was swift to single out the judiciary (which he believes is full of Gulenists) for punishment following the coup. Reports suggest he has ordered the arrest of more than 2500 judges and prosecutors, along with nearly 3000 military personnel who have been detained.

The political prospects for Turkey do not look good. It has a domestic terrorist problem from Islamic State and Kurdish groups, is fighting Kurds in the south east, and is under pressure to control foreign fighters entering and leaving Syria, All of this while hosting hundreds of thousands of Syrian refugees. Turkey, once seen as the exemplar for secular, democratic Islam is no longer viewed in that way. Its tourist trade (accounting for 13% of GDP) has suffered grievously. Still, expect little to change following the coup other than a continued consolidation of power by Erdogan and a purge of his political opponents on a grand scale. As Erdogan told a crowd shortly after restoring control: 'The strong are not always right, but the right are always strong'.

Photo by Defne Karadeniz/Getty Images