Turkey coup 2016 Erdogan Islam
People stand and celebrate on an army tank after taking over military position on the Bosphorus bridge in Istanbul on July 16, 2016, following an attempt by discontented soldiers to seize power from President Recep Tayyip Erdogan that claimed more than 250 lives.BULENT KILIC/AFP/Getty Images)

24 hours after the attempted coup in Turkey, skirmishes were still being reported tonight (16 July), but the response from the government of President Recep Erdogan has been swift. So far 2,839 people suspected of involvement - mostly from the military and parts of the judiciary - have been arrested. There are calls for the return of the death penalty and the government has demanded the US extradites exiled cleric Fethullah Gulen, who Erdogan blames for the failed military uprising.

Gulen denies playing any part in the coup by elements within Turkey's army and air force, deployed to devastating use in bombing the parliament building in Ankara and striking civilians from helicopter gunships. At least 161 civilians were killed and flights to Turkey are still suspended by British Airlines, but with thousands of pro-Erdogan civilians celebrating in Ankara and Istanbul, in Western capitals the prevailing mood of politicians seems to be one of relief.

President Erdogan has long been a divisive figure, seen as part of the Middle East "problem", yet probably essential to any "solution." Erdogan has allowed Western forces to use air bases to bomb Isis, yet isis fighters cross the border with Syria at will. Turkey remains an important part of Nato, yet frequently bombs Kurdish cities in the southeast. Press freedoms are among the worst in the world; this is a democracy yet political dissent is ruthlessly quashed; and even when co-operating with Europe over the migrant crisis, Erdogan's demands were seen by many in Europe as exorbitant. It's more than likely that some of those who voted Brexit were at least partly influenced by the possibility of Turkey becoming a member of the EU - though politicians denied the idea.

Turkey remains officially secular, yet Erdogan has often been keen to embrace Islamism. This was a reason given by those thought to be involved in the coup, as the military has often seen itself as the upholder of secular values despite the country being 98 per cent Muslim. The military has staged a number of coups - from the French coup d'etat, or "blow of state" - most recently in 1997.

Yet for Western governments, perhaps the only thing worse than President Erdogan controlling this country of 80 million people, bridging Europe and Asia, the Middle East and the West, would be a Turkey with no Erdogan at the helm. If Turkey collapsed into full-scale civil war, like Syria to the south, the entire Middle East would be destabilised; Isis could find the way clear to reach Europe; the violence in Syria and Iraq could spill over, drawing in Israel, Iran, the US and Russia.

There may be a temptation for the West to sigh with relief, but the situation in Turkey remains dangerous. Erdogan seems certain to impose even greater control over the military and press, which will antagonise not just the army, but the country's large liberal element. If the military are humiliated, the coup leaders executed, it's possible there could be another attempt - one that remembers which century the world is living in and that the internet, social media and mobile phones make it hard to regulate the flow of information.

Turkey coup: 'We support the democratic institutions of Turkey,' says Boris JohnsonReuters

Whatever happens next, the Kurds will continue to demand an end to repression and perhaps autonomy; Isis will continue to see Turkey as a relatively easy target; and then there's the continuing dispute over Cyprus. The prognosis does not look good. This evening repairs are already underway to patch up the buildings and the bridges damaged by the failed coup. The damage to Turkey's international reputation may take longer to fix.