CAIRO - For Egypt's military chiefs, the final spur to rebellion came on June 26. That day top generals met Mohamed Morsi, the country's first democratically elected president, and spoke bluntly, telling the Islamist leader what he should say in a major speech he planned as protests against him intensified around the country.
"We told him it has to be short, respond to opposition demands to form a coalition government, amend the constitution and set a timeframe for the two actions," an officer present in the room told Reuters. "Yet he came out with a very long speech that said nothing. That is when we knew he had no intention of fixing the situation, and we had to prepare for Plan B."
The officer added: "We had prepared for all scenarios, from street violence to mass clashes, and had troops ready to handle both situations." Like other serving officers interviewed for this report, the person requested anonymity because of the sensitivity of the situation.
As tensions rose over the following days, Morsi remained defiant. In a final telephone conversation with armed forces commander General Abdel Fattah al-Sisi on Wednesday, the president laughed and made light of mass demonstrations against him, a military source said.
"He just didn't believe what was going on," the source familiar with Sisi's contacts said. Any hope that the bearded, bespectacled Morsi would call a referendum on his own future or go quietly, had evaporated.
Soon afterwards, as millions took to the streets, the military executed their plan, confining Morsi as a prisoner in his own Republican Guard compound, arresting key supporters in his Muslim Brotherhood and seizing control of parts of the media. Thus ended the first attempt to graft political Islam and democracy onto the Arab world's most populous and historically powerful state, two and a half years after a popular uprising ousted veteran autocrat Hosni Mubarak.
The ease and abruptness of Morsi's overthrow underlines the fragility of the Arab Spring that toppled a string of Middle East autocrats. Hopes that popular rebellions might lead to democracy taking root remain largely unfulfilled, although the experiment is still in progress in Tunisia.
Morsi's downfall in Egypt, a strategic hinge between the Middle East and North Africa, makes plain the fractured nature of the region and the lack of institutional depth to sustain democracy when the tides of popular opinion change. The result in Egypt and elsewhere are deep divisions and instability.
Morsi's ouster has also renewed the debate around whether democracy and political Islam can co-exist. The Muslim Brotherhood's first taste of power lasted little more than a year. Muslim Brotherhood members in Egypt point to the irony of the West encouraging democracy but quietly supporting a military coup, even if few Western leaders are calling it that.
The military's move has also further exposed the many ways in which the Muslim Brotherhood struggled to govern. Egyptians and investors alike complained that some ministries had descended into chaos, with key positions filled by Muslim Brotherhood stalwarts who knew little of the workings of a modern economy. The Egyptian stock market rallied the day after Morsi's overthrow.
Morsi's own shortcomings were stark, and stand in contrast to the way someone like Nelson Mandela, ailing at the other end of the continent, came to power with a message of unity and forgiveness.
A provincial engineering professor, Morsi was not a natural political leader. He had become the Muslim Brotherhood's presidential candidate only when the party's first choice was disqualified. Nevertheless, the novice president appeared decisive on taking office, practising a winner-takes-all interpretation of power that alienated a wide swath of secular and Islamic opponents.
Soon after he was elected in June 2012 with 51.7 percent of the vote, Morsi ordered Egypt's two top generals to retire; one was Field Marshall Hussein Tantawi, a veteran who had served Mubarak for 20 years. It seemed a significant break with the past.
Morsi's choice as the new head of the army was General Sisi, 58, a career infantry officer who had been groomed for a top role with spells as a field commander, studies at a U.S. war college and a stint as a military attache in Saudi Arabia. Sisi was also a devout Muslim and seemed a good fit with Morsi and his Muslim Brotherhood sponsors, who wanted the military to take a back seat after decades of being the real power.
But relations between Morsi and his new generals deteriorated within months of his inauguration. Even Morsi's apparent success in brokering a ceasefire between Israel and the Hamas Islamist movement that runs the Gaza Strip irked the military.
"Morsi's intervention in the Gaza war made Egypt guarantee that Hamas would not carry out attacks on Israel. Which threatens Egyptian national security, because what if Hamas did? It could prompt Israel to retaliate against us," the security source said.
Morsi also talked loosely about possible Egyptian participation in a jihad (holy war) to overthrow Syria's President Bashar al-Assad, and raised the prospect of military action over a Nile River dam in Ethiopia. As a result, distrust of him grew in Egypt's high command, which saw him as recklessly risking their involvement in conflicts without properly consulting and respecting the generals.
"It reached a point where we began to be worried about putting important national security reports in front of someone we perceived as a threat to national security," the security source said.
The generals became equally alarmed about political and sectarian polarisation in Egypt, against a backdrop of a sharply worsening economy. They had secured their own position in an Islamist-tinged constitution rammed through by Morsi's allies last December, ensuring they would remain a state within a state, with limited parliamentary scrutiny of their economic privileges, armaments contracts and control of the vital Suez Canal. But they were increasingly concerned by what they saw as a risk of civil war.
By the time Morsi took office, Egypt's economy, which had boomed for the rich with scant improvement for the poor in the late Mubarak years, was already in deep trouble. The military council which ruled in the 16-month transition from Mubarak's overthrow to Morsi's inauguration had failed to carry out long-overdue reforms of food and fuel subsidies or to negotiate a loan deal with the International Monetary Fund for fear of sparking unrest. Tourism and investment had dried up because of political instability.
Morsi's bumbling, do-little administration only made things worse. While the Muslim Brotherhood remained the most powerful political force and ran a social welfare network that provided services to the poor and needy, millions of Egyptians felt no one was representing their interests.
Youth activists of the Tamarud - Rebel! movement launched a petition on May 1 demanding Morsi's resignation; it snowballed, receiving what they say were more than 22 million signatures. They called for nationwide protests on June 30, the first anniversary of his inauguration.
Angered by the Muslim Brotherhood's perceived power-grabbing and economic incompetence, Egyptians turned out in their millions to shout "Erhal!" (Get out!). Counter-demonstrations by Morsi's supporters drew a few hundred thousand people but were clearly outnumbered by the malcontents.
The day after the June 30 protests, Sisi issued a 48-hour ultimatum to Morsi: either yield to the protesters' demands that he share power with the opposition, or make way for the military to impose a solution. In two private meetings with the president on July 1 and 2, the armed forces chief was even more blunt with the president, but met with incomprehension and rejection, a military source briefed on the meetings said.
"General Sisi went to him and told us when he came back, 'He was in denial, he said the protesters are just 130,000 to 160,000, but I told him 'No, sir, they are far more than that and you must listen to their demands'', the source said.
"In the second meeting, General Sisi went with a video recording of the protests the army had made and told him 'Sir, the situation is out of hand and your suggestions to change the government or the constitution are now too late and will not satisfy the street. I suggest you call a referendum on your continued rule.' But he refused and said this is unconstitutional and illegitimate," the source said.
Faced with the president's refusal, Sisi intensified contacts with Mohamed ElBaradei, the senior liberal politician nominated by the National Salvation Front (NSF) opposition coalition as their negotiator with the army, and with the country's revered Muslim and Christian leaders, Grand Sheikh Ahmed al-Tayeb of the al-Azhar Islamic institute and Pope Tawadros of the Coptic Church. Both had publicly blessed the protest movement.
The army chief also made the savvy move of including the young founders of Tamarud - Rebel! and a leader of the second largest Islamist party, the ultra-conservative Salafist Nour party, an open rival of the Brotherhood for Muslim hearts and minds.
They all met at the headquarters of military intelligence on El-Thawra (Revolution) Street on Wednesday, July 3 - the day the ultimatum was set to expire - to thrash out a roadmap for the country's second attempt at a transition to democracy. The meeting lasted about six hours, short by Egyptian standards. The army effectively adopted the blueprint put forward by Tamarud and endorsed by the NSF.
"General Sisi tried to contact the Muslim Brotherhood leader to suggest a referendum option, but he along with others refused to come," the military source said. "He also offered it to the politicians and others, but Tamarud members refused it, and the others agreed to almost everything Tamarud suggested."
The twentysomething activists who controlled the street were calling the shots.
Outsiders were also concerned, not least because Egypt receives significant U.S. aid and Morsi represented a rare beacon of democracy in the region. U.S. President Barack Obama, on a visit to Tanzania, telephoned Morsi on Monday July 1 and urged him to respond to the demands of the protesters, the White House said.
John Kerry, U.S. Secretary of State, told reporters while travelling in the Middle East last week: "We have made many recommendations to our friends in Egypt. We are trying to help, as other countries are trying to help, to create a place for the opposition to be part of the political process in order to create some economic reforms that will help attract business and capital and begin to move their economy."
Yet senior U.S. officials doubted Morsi's ability to unite the country and resolve the looming crisis. Behind the scenes, Chuck Hagel, the U.S. Defense Secretary, was talking to Sisi, the Pentagon later said. It declined to say what the two men discussed, but mutual interests abound: Egypt controls the Suez Canal, through which large amounts of oil travel to the West; the United States provides $1.3 billion a year to Egypt's military.
How much the United States knew in advance about the Egyptian military's intentions is uncertain.
In recent months U.S. Ambassador Anne Patterson had nudged Morsi publicly and privately to be more inclusive, but she continued to stress that he was a legitimate leader, fuelling a widespread perception in Egypt that the United States was backing the Brotherhood, and its Qatari sponsors, who lent Cairo some $7 billion to keep the economy afloat.
What is clear is that despite Patterson's public statements underlining Morsi's democratic legitimacy - which drew sharp criticism in Egyptian media - there was no red light from Washington against military takeover.
Last Sunday as at least 500,000 people massed in and around Cairo's Tahrir Square - and millions more around the country - a remarkable repositioning of sympathies was taking place.
In 2011 when protesters sought the downfall of Mubarak, a former air force commander, the crowds had feared the military would attack them. Instead, the army had sided with "the people" and forced their autocrat out.
Now, as an army helicopter flew over the crowd in Tahrir Square dropping Egyptian flags, protesters roared approval. The military said the move was intended to encourage patriotism, not signify political support, but the implication was clear: the protesters confronting Morsi need not fear the army.
The military supplied aerial video of the vast throngs of anti-Morsi demonstrators to television stations to demonstrate the sheer scale of support for his removal. "What we have now is an information war with the Muslim Brotherhood," the military source said.
That night militant protesters targeted the Muslim Brotherhood's national headquarters, a four-storey building in a suburb of Cairo. Police and fire fighters were nowhere in sight. The protesters smashed windows, looted the furniture and set fire to the building - a moment that recalled the destruction of the state security headquarters when Mubarak fell.
After months of trying in vain to get the president to reach a power-sharing accommodation with his liberal, nationalist and left-wing opponents, Sisi acted. Egypt's armed forces gave Morsi 48 hours to strike a deal with his opponents or have the army impose its own road map for the country.
On state television Sisi declared: "If the demands of the people are not realised within the defined period, it will be incumbent upon (the armed forces) ... to announce a road map for the future."
The army said it would oversee the implementation of the road map "with the participation of all factions and national parties, including young people," but it would not get directly involved in politics or government.
Morsi did not immediately respond. But the bitter irony was clear: the army that the 2011 revolutionaries had hoped would stay out of politics was presenting an ultimatum to the elected president. Morsi's supporters were quick to make the point. Hassan al-Sherbeny, demonstrating near a Cairo mosque, said: "The world always thought we Islamists didn't believe in democracy. Now Islamists are teaching Egyptians democracy while the liberals are giving up democracy. And where is the world's reaction to that?"
The world's public reaction was muted. In private, U.S. Defense Secretary Hagel again spoke to Sisi, the Pentagon said. Another Egyptian general also spoke to the chairman of the U.S. Joint Chiefs of Staff, General Martin Dempsey.
"We understood from some communication exchanged between top officials from our side and the Americans and Saudis, and intelligence reports, that the Americans will not be very happy with our intervention, but we did not care," an Egyptian army source briefed on the conversation said. "We knew that we have the people's support."
The linguistic contortions to which the U.S. administration resorted to avoid calling the military takeover a coup - President Barack Obama described it as "the decision of the Egyptian Armed Forces to remove President Morsi and suspend the Egyptian constitution" - made clear Washington was unwilling to condemn it.
The public and private stance of regional allies was more enthusiastic about the army's move.
"The countries most supportive are Saudi Arabia, Kuwait and the United Arab Emirates because they understand Egypt's strategic importance to the Arab and Islamic world and fear the expansion of the Brotherhood," another security source said. "They also know that the end of the Brotherhood in Egypt is the end of the Brotherhood in the Arab world."
When Morsi finally reacted to Sisi's ultimatum, he rebuffed the army and said he would pursue his own plans for national reconciliation.
"The president of the republic was not consulted about the statement issued by the armed forces," said Morsi's office. "The presidency confirms that it is going forward on its previously plotted path to promote comprehensive national reconciliation."
With protesters besieging the main Ittihadiya presidential palace, Morsi had been moved for his own safety to the nearby Qubba palace, once the official residence of King Farouk who himself was toppled by a military coup in 1952. On Wednesday, Morsi was driven to his reserve office in the Republican Guard compound near Cairo airport.
On his last day at work there, apparently oblivious to his impending downfall, Morsi conferred with aides and carried on with business as usual as the clock ticked down.
"The president is still the president and he is still sitting in his office, with his team," said Yaser Haddara, a communications adviser to Morsi, speaking by mobile phone from inside the compound at around 6 p.m. on Wednesday, an hour after the army ultimatum expired. "The general mood is actually quite comfortable. People are working, believe it or not."
Most of his staff were ushered out of the building shortly afterwards.
At around 7 p.m., Sisi called Morsi and asked him one last time if he would agree to a referendum on his continuation in office or to hand over to the speaker of parliament, the source said. The president demurred and the general told him he was no longer president. Morsi and his closest aide, national security adviser Essam El-Haddad, were effectively placed in detention at the compound and told they could not leave for their own safety.
"He was treated with respect because we don't want to destroy his image as a president of Egypt," the military source said, adding that the army had been upset at seeing Mubarak, a former airforce commander, paraded behind bars in a courtroom cage after he was ousted.
The last that many Egyptians saw of the man who won 13 million votes in the first free presidential election just a year earlier was a shaky video clip posted on YouTube showing Morsi, seated at his desk, denouncing the military takeover and calling for peaceful resistance.
While Morsi was his usual repetitive, long-winded self in his final broadcast, Haddad posted a forensic 885-word analysis of his boss's downfall on his official Facebook page.
"As I write these lines I am fully aware that these may be the last lines I get to post on this page," the Birmingham-trained doctor wrote. "For the sake of Egypt and for historical accuracy, let's call what is happening by its real name: Military coup."
If the army intervention prevailed, he wrote, "the message will resonate throughout the Muslim world loud and clear: democracy is not for Muslims. Many have seen fit in these last months to lecture us on how democracy is more than just the ballot box. That may indeed be true. But what is definitely true is that there is no democracy without the ballot box."