To mount a coup, senior Turkish army officers from the commando units, land forces, the first and fourth armies, and the airforce went to extreme lengths to seize power.
They occupied two airports and closed a third. They attempted to separate the European from the Asian sides of Istanbul. They bombed the parliament in Ankara nine times. There was a pitched battled outside the headquarters of MIT the Turkish intelligence agency. They deployed tanks, helicopter gunships and F16 jets.
To defeat the coup, the Turkish president used his iPhone. Mosques used their loudspeakers, broadcasting the call to prayer hours before dawn. Political leaders of all creeds, some staunch opponents of the president, called unambiguously for the coup to be defeated. Policemen arrested soldiers.
Unarmed people recaptured CNN Turk and the bridges across the Bosphorus, braving gunfire to recapture democracy for their country.
This was unambiguously a military coup. And yet the US Embassy in Ankara in its emergency message to US citizens called it an “uprising”.
Geopolitical Futures released an analysis saying the coup was successful. BBC Arabic, Sky News Arabic, El Arabiya TV, the ITN diplomatic editor, the US networks were all running commentaries saying Erdogan was finished, or had fled to Germany.
The Guardian ran a piece whose first headline (it was later amended) said everything about an author unable to contain his glee at the demise of a man he qualified as authoritarian islamist: “How Recep Tayyip Erdogan inflamed tensions in Turkey”.
As the people of Turkey battled for their future, there was a crashing silence from Western leaders whose brand image is democracy. The French consulate had closed two days earlier. Did it know something Turkey did not?
In his initial statement, US Secretary of State John Kerry used every word except the dreaded “d” one. He hoped for “stability and peace and continuity” within Turkey.
Nothing about supporting a legitimately elected president and a legitimately elected parliament. Only when it was already obvious that the coup was failing did President Barack Obama and Kerry issue a statement unambiguously backing Erdogan.
If you want to know why Europe and the US are a busted flush in the Middle East, why they have lost all moral authority, indeed any authority at all, and why they are no longer the candle bearers of democratic change, look no further than the three hours of silence as they waited to see which way the wind was blowing in Istanbul and Ankara.
The Saudis waited 15 hours before issuing a statement supporting Erdogan. The Emiratis and the media they controlled spread the message that Erdogan had fled the country.
The exact opposite was the truth. Erdogan showed bravery getting into a plane and heading for Istanbul knowing F16s were in the air and that the runway at Ataturk airport could have been closed.
Only three countries in the world clearly supported Erdogan from the start - Morocco, Qatar, and Sudan.
What was particularly impressive were the statements of Turkish politicians who had every reason to want Erdogan to go, and who had themselves been displaced by him. To his credit, the leader of Turkey’s largest party, Kemal Kalicdaroglu of the centre-left People's Republican Party (CHP), came out immediately against the coup in a series of tweets, saying the country has "suffered a lot" in past military takeovers.
Two AK Party leaders from the liberal wing, who had been displaced or recently sacked by Erdogan supported him. Former president Abdullah Gul told CNN Turk that "Turkey is not a Latin America country ... I'm calling those who attempt to overthrow the government [they] should go back to their barracks."
Former Turkish prime minister Ahmet Davutoglu told Al Jazeera: "Turkey is a democracy ... I don't think this attempt will be successful. There cannot be any attempts to destabilise Turkey. We're facing so many crises in Syria and other regions, it's time to have solidarity with the Turkish people... At this moment people in different cities are in the streets, the squares [protesting] against this coup d'etat attempt.”
All these people could see what the Western consensus about Erdogan could not. That the process was more important than the man. That Turks, believe it or not, would fight and die for the right to elect their president, even though the majority clearly do not want him to have overriding presidential powers.
Turkey’s reaction last night was that of a mature democracy. The Western reaction was that of corrupted democracy, terminally tainted by its military and political support of autocracy.
The turning point in last night’s morality play in Turkey came when images of Erdogan speaking into his iPhone were broadcast and spread virally over social media.
Up until then, it looked as if the coup would succeed. He called for the people to come out onto the streets and stay out on them. And they heeded that call sometimes at the cost of their own lives. An iPhone defeated tanks.
Turkey proved it is not Egypt. If there is a lesson in these dark days for democracy in the Middle East, it is for the people who are living the other side of the Mediterranean and whose country is bleeding from the military autocracy it once hailed as a second revolution.
Not for the first time since 2011, autocrats across the region must be shivering today. The democratic forces which can disarm soldiers, can disarm them too.
- David Hearst is editor-in-chief of Middle East Eye. He was chief foreign leader writer of The Guardian, former Associate Foreign Editor, European Editor, Moscow Bureau Chief, European Correspondent, and Ireland Correspondent. He joined The Guardian from The Scotsman, where he was education correspondent.