Army concern about the way President Mohamed Morsy was governing Egypt reached tipping point when the head of state attended a rally packed with hardline fellow Islamists calling for holy war in Syria, military sources said.
At the June 15 rally, Sunni Muslim clerics used the word "infidels" to denounce both the Shi'ites fighting to protect Syrian President Bashar al-Assad and the non-Islamists that oppose Morsy at home.
Morsy himself called for foreign intervention in Syria against Assad, leading to a veiled rebuke from the army, which issued an apparently bland but sharp-edged statement the next day stressing that its only role was guarding Egypt's borders.
"The armed forces were very alarmed by the Syrian conference at a time the state was going through a major political crisis," said one officer, whose comments reflected remarks made privately by other army staff. He was speaking on condition of anonymity because he was not permitted to talk to the media.
The controversy surrounding the Syria conference pointed to a crippling flaw in the Morsy presidency: though the constitution names Morsy as supreme commander of the armed forces, the military remains master of its own destiny and a rival source of authority to the country's first freely elected head of state.
The army's dramatic ultimatum demanding Morsy and other politicians settle their differences by Wednesday afternoon caught the presidency completely off guard. Triggered by mass protests against Morsy's rule, it amounted to a soft coup by a military that has been a major recipient of U.S. aid since the 1970s, when Egypt made peace with neighbouring Israel.
The army has cited the need to avoid bloodshed as its main motivation. It is also worried by other major problems facing Egypt, including an economic crisis that has wiped out more than a tenth of the value of the currency this year, making it harder for the state to import fuel and food.
Speaking on the eve of the protests, the president had dismissed the idea that the army would take control again.
If Morsy was aware of irritation in the army, he chose to ignore it, believing his mandate as Egypt's democratically elected leader gave him licence to make policy the way elected leaders do elsewhere in the world.
For the army, the Syria rally had crossed "a national security red line" by encouraging Egyptians to fight abroad, risking creating a new generation of jihadists, said Yasser El-Shimy, analyst with the International Crisis Group.
At the heart of the military's concern is the history of militant Islam in Egypt, homeland of al Qaeda leader Ayman al-Zawahri. The military source condemned recent remarks made by "retired terrorists" allied to Morsy, who has deepened his ties with the once-armed group al-Gamaa al-Islamiya.
Speaking privately, officers in the secular-leaning military have said Egyptians did not want a religious state. Though the Brotherhood never said it wanted to set up a theocracy, such concerns reflect the army's long-standing suspicion towards a movement banned by army rulers in 1954.
PRESIDENCY DIDN'T SEE THREAT
In public, Morsy and the army have kept up appearances.
The presidency has moved repeatedly to quash rumours of tensions with the generals.
And the constitution signed into law by Morsy late last year protects the interests of the military, which oversees a sprawling economic empire that produces everything from bottled water to tablet computers.
"The presidency didn't perceive the military as a threat," added Shimy of the International Crisis Group.
The current head of the armed forces, General Abdel Fattah al-Sisi, was appointed by Morsy in his second month in office after he sent into retirement Field Marshal Hussein Tantawi, Mubarak's defence minister for two decades.
Twenty years Tantawi's junior, Sisi was promoted from the position of military intelligence director. Analysts have described it as an arrangement that suited both Morsy and a younger generation of army commanders seeking promotion.
He was trained in the United States and Britain, like many officers in an army that receives $1.3 billion in military aid a year from Washington.
While saying the army was out of politics, Sisi has repeatedly called on Egypt's feuding politicians to settle their differences. In December, he chaired unity talks to ease tensions ignited by a decree that expanded Morsy’s powers.
Earlier this year, Sisi warned that unrest could bring down the state. He also responded to calls for the army to unseat Morsy, saying: "No one is going to remove anybody".
The army has not said what Morsy’s fate will be in the plan which it will implement if the politicians fail to agree.
Sisi is something of an Islamist himself, said Robert Springborg, an expert on the Egyptian military based at the Naval Postgraduate School in Monterey, California. He was citing materials written by Sisi during his training in the United States. "As I see it they are trying to assert as much pressure as possible to bring about a compromise settlement," he said.
The military's actions this week should be viewed as those of an institution, not individuals, added Nathan Brown, an expert on Egypt at George Washington University.
"The personal inclinations of individual members of the armed forces are not the issue and are not on display here.
"There is one thing we do know about the ideology of the military," he said: "That it sees itself as having a mission to the state rather than the constitution."