Egypt’s generals ousted King Farouk in 1952 and established a republic a year later. Turkey’s first president, Mustafa Kemal Ataturk, a military revolutionary, led a fierce secularization drive in the 1920s. Pakistan’s military helped unify the country after its traumatic partition from India in 1947, and quickly established itself as the strongest arm of a weak state.

Pakistani, Turkish and Egyptian generals profess to love democracy, but they practice it with varying degrees of reluctance. After seizing power in Pakistan in 1999, General Musharraf promised early elections but stayed for nine years. During a stint at the United States Army War College in 2005, General Sisi wrote a paper titled “Democracy in the Middle East” that was critical of American intervention in the region. Turkey’s army has claimed a popular mandate for inherently undemocratic acts.

Instead, the military has deeply embedded itself in each state’s DNA, winning privileges and lucrative jobs for its officers, all the while controlling politics in blunt fashion. Pakistan’s generals have mounted four coups over the past 55 years; Turkey has had three. In both Pakistan and Egypt, analysts describe the military as the core of the “deep state.”

“The military has been very influential since the 1952 revolution,” said Hala Mustafa, editor of the Journal of Democracy in Cairo. “Even under Morsi, it had the same privileges and status as it had over the past six decades.”

How the militaries exercised that influence has varied. While Turkish and Egyptian generals ruthlessly marginalized political Islamists, Pakistan’s men in uniform co-opted them. During the 1980s, Gen. Mohammad Zia ul-Haq of Pakistan used them to both fight and to Islamize Pakistan’s national identity, a source of tension with Egypt at the time.

In all three countries, Islam is often seen as the boogeyman of democracy, Dr. Nasr said. “But that is wrong. The real struggle in the Middle East is between civilian rule and the military.”