The assumption that popular opinion has an impact on coups is common in political science, but there is no evidence to support it:
Over the course of writing my book, “Seizing Power: The Strategic Logic of Military Coups,” I spent 300 hours talking with participants in 10 coup attempts in Ghana and statistically analyzed the determinants of every coup attempt and outcome in the world from 1950 to 2000. Based on this evidence, I argue that there is no reason to believe that military factions hesitate to attempt coups when popular opinion is against them, or that coup attempts are more likely to fail when the populace is opposed.
Over the course of this research, I observed that conspirators devoted very little consideration during coup plotting to the question of how the population would react. Coup makers are largely convinced that their cause is just (even when the coup comes from a partisan or personal interest), and that they will have widespread popular support for their actions, with perhaps limited opposition coming from entrenched special interests. And, in general, coup attempts do encounter very little popular protest, although this is not a reflection of support for military intervention. Coup attempts generally transpire very quickly and, with a few noteworthy exceptions, are over before civilians can mobilize in opposition. If a coup succeeds, civilians respond strategically. Opponents of the previous government will rejoice, joined by opportunists who wish to curry favor with the new rulers. Supporters of the previous government will usually remain quiet, afraid of bringing attention to themselves. Because successful coups are generally met with expressions of popular support, it spuriously appears that public opinion had a role in encouraging the conspirators to act.
The whole point of a coup is for a faction of the military to take over the government without kicking off a civil war:
That means that coups are typically marked by defections to whatever side appears to be winning, rather than outright military conflict between factions.
[...]
One critical way to create this self-fulfilling prophecy, according to Singh’s research, is to take control of the broadcast media. Once you’ve got the radio and television stations, you then use them to tell everyone the government has already been overthrown. That convinces people in the military that the coup has succeeded, leading them to take your side.
But reports on the ground say that this didn’t happen. President Erdogan managed to make a televised statement opposing the coup (though he did so, amusingly, via a cellphone on Skype). Leaders of major political parties, including the opposition, publicly opposed the coup.
Perhaps most importantly, the coup plotters did a very poor job of getting their message out. While they did seize a number of media outlets, like CNN Turk, they failed to use them effectively in broadcasting their message.
“We had no clear statement from the coup forces. No leader came on TV, no real manifesto,” Zeynep Tufekci, a professor at the University of North Carolina who was in Turkey during the coup attempt, tweeted. “In Turkey, successful coup attempts are massive, happen within chain-of-command, and take over media immediately.”
The coup plotters failed to establish the perception that they were fully in control, and hence failed to win the overwhelming bulk of the military to their side. It’s still early, so we can’t be sure of anything. But given Singh’s research, and the information we have, it’s very likely that this explains — at least in part — why they failed.
“In Turkey, successful coup attempts are massive, happen within chain-of-command, and take over media immediately.”
And here the success of Erdogan’s earlier purges of Kemalist generals became evident:
The Coup plotters lacked the high level access to arrest or assassintate Erodgan and other top ranking members of his regime. They also lacked the necessary authority to bring in more of the military.
Erdogan’s Islamast (anti-Kemalist) purgings of the Turkish top level may not have been enough to stop all coup attempts but it was enough to render all coup attempts stilllborn.