It was a strangely 20th century coup, defeated by 21st century technology and people power.
When a self-styled military "Peace Council" tried to topple Turkish President Tayyip Erdogan and his increasingly authoritarian government on Friday night, the rebel generals and colonels seemed to be fighting the last war.
"This coup was obviously planned quite well but using a playbook from the 1970s," said Gareth Jenkins, a researcher and writer on military affairs based in Istanbul.
It was more like Chile in 1973, or Ankara in 1980 than a modern Western state in 2016.
The rebels struck on a weekend when the president was out of town at a holiday resort. They seized the main airport, sealed off a bridge over the Bosphorus in Istanbul, sent tanks to parliament and Ankara and to control the main road junctions, and broadcast a statement on TRT state television declaring a curfew and warning people to stay at home.
But they failed to capture any of the ruling AK Party leaders or to shut down private television, mobile phone signals or social media networks, enabling Erdogan and his aides swiftly to call supporters into the streets to resist the coup.
Their biggest handicap, said Turkish analyst Sinan Ulgen of the Carnegie Europe think tank, was that they acted outside the military chain of command and hence lacked sufficient resources to take control of key levers of power.
"Their blueprint was also ineffective since they failed from the outset to capture any military installations in Turkey or any of the (political) leadership," said Ulgen, a former Turkish diplomat.
Erdogan, frequently accused of interfering with social media and muzzling the press and broadcasters, used modern communications technology nimbly to get his message out to the population of nearly 80 million, outflanking the plotters.
A supporter of Turkish President Tayyip Erdogan celebrates with flag on top of a police car in Ankara, Turkey, July 16, 2016.
He used the FaceTime video application on a reporter's smartphone to broadcast a message live on CNN Turk, a private TV station which the plotters tried but failed to silence.
"Let's gather as a nation in the squares," he said. "I believe we will remove this occupation that has taken place within a short time. I am calling on our people now to come to the arenas and we will give them the necessary answer."
The president said rebels tried to bomb his hotel in the southwestern resort of Marmaris. There was also a gunfight there between soldiers and pro-government police after he had left.
Within 20 minutes of the coup broadcast, Prime Minister Binali Yildirim went on Twitter to denounce the putsch and assure Turks that the armed forces' high command was not backing the revolt.
They were following in a long line of revolutionaries who used new communications techniques to outwit their enemies -- from Protestant priest Martin Luther using the printing press in 1517 to spread his theses denouncing the Roman Catholic church, to Ayatollah Ruhollah Khomeini recording audio cassettes in France that were copied and spread around Iran to defeat the Shah in 1979.
Social media have made it harder for governments to suppress news and voices of protest. Iran's "Green Revolution" protests against an allegedly rigged presidential election in 2013 were amplified by video shot on mobile phones and disseminated on YouTube, Facebook and Twitter.
In Turkey on Friday, aides to Erdogan were able to get messages out to Turkish and international media that the president, in power since 2003, was safe and not under arrest even as soldiers were taking over the TRT television station.
His predecessor, Abdullah Gul, also used FaceTime to shout angry defiance at the coup plotters on CNN Turk, and former Prime Minister Ahmet Davutoglu spoke by mobile phone with Al Jazeera television to call the takeover a failure.
The contrast was striking with the ultimately unsuccessful 1991 coup by hardliners against Soviet President Mikhail Gorbachev, who was reduced to listening to BBC World Service radio at his Crimean holiday home, powerless to intervene as events unfolded in Moscow.
The Soviet plotters managed to take control for three days -- earning embarrassing recognition from then French President Francois Mitterrand -- before Russian leader Boris Yeltsin rallied public opposition to the coup, standing atop a tank in Moscow to harangue the crowd.
The Turkish events also had echoes of a 1981 coup attempt against Spain’s young democracy by rebel officers who burst into parliament but failed to win broader military support after King Juan Carlos broadcast to the nation in military uniform urging people to uphold the constitution.
As in the failed Soviet coup, the Turkish coup leaders were dependent on raw conscripts who had either not been told the truth about their mission, or had not expected to face popular resistance and quickly melted away or surrendered.
"Fear in their eyes"
All three opposition party leaders quickly condemned the coup and social media amplified calls to demonstrate against it.
Supporters of Tukish President Tayyip Erdogan celebrate after troops involved in the coup surrendered, in the resort town of Marmaris, Turkey July 16, 2016.
The rebels bungled an attempt to silence CNN Turk, jointly owned by Turner Entertainment Systems of the United States and Dogan Yayin Holding. A helicopter carrying conscripts with a single officer landed at the station but was told it was impossible to take the signal off the air.
They forced the temporary evacuation of the studio. When CNN Türk came back on air, anchorwoman Nevsin Mengu and general manager Erdogan Aktas described the mood of the young soldiers.
"These young soldiers had only fear in their eyes and no sign of devotion or determination," Mengu said. "They asked us to go offline but we said it was not doable. They didn't know how to do it so our empty studio was live on TV for the whole time before we regained control."
During that break, a man in a pink T-shirt wandered into the studio chanting "Allahu Akbar" (God is great) in support of Erdogan. Religious leaders loyal to the president also for the first time used the network of mosques with loudspeakers to urge Turks to go out into the streets in the name of "jihad" (holy war).