Something extraordinary happened in Turkey at the weekend. A fully fledged military coup, complete with tanks in the streets, was foiled by people armed with no more than their mobile phones. They responded to a call from President Recep Tayyip Erdogan, whose own autocratic tendencies have been a worry to many modern Turks but clearly they prefer him to another period of military rule.
The coup outcome is troubling, in that arrest warrants have been issued for 2745 judges as well as the nearly 3000 military personnel said to be involved. The numbers suggest a power struggle of worrying proportions has divided institutions of the state. But the outcome is also hopeful for the survival of democracy in a country that plays a crucial strategic role in the modern world, straddling the divide between the West and the Middle East.
All parties in Parliament joined the President in resisting a military takeover and the Parliament came under attack before the crowds gathering in the squares of Ankara and Istanbul stopped the tanks and the soldiers surrendered to police.
It has been a powerful demonstration of the ability of social media to summon crowds in time to stop unconstitutional seizures of control, but the success of popular resistance will always depend on the political culture of a country and the ruthlessness of those in power or seeking power. Social media would probably not carry the day in Saudi Arabia or Tiananmen Square.
For Turkey, though, the events may have been cathartic. Turkey has seen four successful coups since 1960, the last as recently as 1997 when the army did not even need to demonstrate its power. The chief of staff simply made an announcement on its website. This time, though army units were stationed at strategic points and aircraft flew low over the cities, the coup leaders saw no need to silence the President or Parliament before they made their move. They gave a statement to the state television channel in Ankara that was duly broadcast.
But later in the evening television viewers saw what many were also seeing on their phones - the President speaking on his phone to urge them to come to the main squares and defend their democracy. Those who stayed in, watching TV, heard the state channel reverse its previous announcement, though in the early hours of the morning an army unit stormed the studios and viewers watched journalists resist its attempt to take control of the news. Turks have described the whole drama as bizarre and surreal but it could have turned out differently.
The outcome will have greatly strengthened Erdogan's position, which has not been universally welcomed. He has posed just as great a threat to press freedom and the rule of law in recent years. Turkey is not immune to the religious revivalism in Islamic countries and Erdogan has been leaning towards Islamism lately. Mosques helped sound the alert on the night of the coup. But having summoned democracy to his side, the President may need to be more willing to honour it.