CAIRO - The head of Egypt's military, Gen. Abdel-Fattah el-Sissi, sat with a polite smile in the front row listening to President Mohammed Morsi give a 2 1/2-hour speech defending his year in office. El-Sissi even clapped lightly as the audience of Morsi supporters broke into cheers.
It was a calculating display of cool by an army general plotting the overthrow of his commander in chief. Just over a week later, el-Sissi slid in the knife, announcing Morsi's ouster on state TV on July 3 as troops took the Islamist leader into custody.
The move was the culmination of nearly a year of acrimonious relations between el-Sissi and Egypt's first freely elected - and first civilian - president.
A series of interviews by The Associated Press with defense, security and intelligence officials paint a picture of a president who intended to flex his civilian authority as supreme commander of the armed forces, issuing orders to el-Sissi. In turn, the military chief believed Morsi was leading the country into turmoil and repeatedly challenged him, defying his orders in at least two cases.
The degree of their differences suggests that the military had been planning for months to take greater control of the political reins in Egypt. When an activist group named Tamarod began a campaign to oust Morsi, building up to protests by millions nationwide that began June 30, it appears to have provided a golden opportunity for el-Sissi to get rid of the president. The military helped Tamarod from early on, communicating with it through third parties, according to the officials.
The reason, the officials said, was because of profound policy differences with Morsi. El-Sissi saw him as dangerously mismanaging a wave of protests early in the year that saw dozens killed by security forces. More significantly, however, the military also worried that Morsi was giving a free hand to Islamic militants in the Sinai Peninsula, ordering el-Sissi to stop crackdowns on jihadis who had killed Egyptian soldiers and were escalating a campaign of violence.
"I don't want Muslims to shed the blood of fellow Muslims," Morsi told el-Sissi in ordering a halt to a planned offensive in November, retired army Gen. Sameh Seif el-Yazl told AP. Seif el-Yazl remains close to the military and sometimes appears with el-Sissi at public events.
And at root, the military establishment has historically had little tolerance for the Muslim Brotherhood, Morsi's Islamist group. The military leadership has long held the conviction that the group puts its regional Islamist ambitions above Egypt's security interests.
Its alliances with Gaza's Hamas rulers and other Islamist groups alarmed the military, which believed Gaza militants were involved in Sinai violence. The officials said the military leadership also believed the Brotherhood was trying to co-opt commanders to turn against el-Sissi.
The military has been the most powerful institution in Egypt since officers staged a 1952 coup that toppled the monarchy. Except for Morsi, the military has since given Egypt all of its presidents and maintained a powerful influence over policy. Having a civilian leader over the military was entirely new for the country.
The Brotherhood accuses el-Sissi of turning against them and carrying out a coup to wreck democracy. Since being deposed, Morsi is detained by the military at an undisclosed Defense Ministry facility.
The Brotherhood had believed that el-Sissi was sympathetic with their Islamist agenda. A senior Brotherhood official told AP that Morsi installed el-Sissi, then the head of military intelligence, as defense minister and head of the armed forces in August 2012 in part because he had been the contact man between the Brotherhood and the military junta that ruled Egypt for nearly 17 months after the February 2011 fall of autocrat Hosni Mubarak.
El-Sissi spoke of his differences with Morsi for the first time Sunday when he addressed military officers in a meeting that was partially televised.
"I don't want to count to you the number of times that the armed forces showed its reservations on many actions and measures that came as a surprise," el-Sissi said.
Along with the Brotherhood official, eight current senior officials in the military, military intelligence and Interior Ministry - including a top army commander and an officer from el-Sissi's inner circle - spoke to AP on condition of anonymity because they were not authorized to discuss the events between Morsi and the military.
They recounted tense conversations and meetings with a frustrated Morsi frequently reminding the military chief of his rank as supreme commander.
As early as April, the army drew up a contingency plan to assert control of the nation by taking charge of security if street violence escalated out of Morsi's control, the intelligence and defense officials said.
The plan did not entail removing Morsi. Instead, it was an expansion of the role the army took in the Suez Canal city of Port Said, which by that time had seen months of anti-Morsi protests that evolved into an outright revolt. More than 40 protesters had been killed by police there, as Morsi publicly urged security forces to deal strongly with the protests. The military was deployed in the city, largely welcomed by the residents, who continued protests and strikes.
The military officials said Morsi had ordered the army to get tougher on protesters, but el-Sissi refused, telling him, "The people have demands."
About this time, in April and May, el-Sissi's officials met with commanders of the Republican Guard, the army branch that protects the president. The commanders told them that Morsi's aides were trying to co-opt Guard officers and senior army officers in a move to replace el-Sissi, according to the official in the military chief's staff.
Each side's suspicions were fueled by leaks in the press with anonymous Brotherhood and military officials quoted as criticizing the other. In meetings, Morsi assured el-Sissi that he had no intention of firing him, saying, "These are just rumors," the defense officials said. El-Sissi told Morsi that the military leaks were merely "newspaper talk."
In April, the youth activists of Tamarod, Arabic for "Rebel," began collecting signatures on a petition for Morsi to step down. When it said it had 2 million signatures in mid-May, the military took an interest and worked through third parties that connected the group with liberal and opposition-linked businessmen who would bank it, said two high-ranking Interior Ministry officials.
The campaign claimed in June to have more than 20 million signatures - though the number has never been independently confirmed - and called for mass rallies against Morsi to start June 30, the anniversary of his inauguration. El-Sissi issued a statement saying the armed forces would intervene to stop any violence at the protests, particularly to stop Morsi supporters from attacking the rallies. He gave the two sides a week to resolve their differences - with the deadline being June 30.
The protection plan appeared to be an evolution of the original contingency plan set up in April, and it was widely seen as a show of support for the protesters.
Morsi summoned el-Sissi to explain his statement, and the general reassured him that "this was designed to calm people down," the Brotherhood official said.
"He did not show his true intentions until July 1 when he gave the president a 48-hour ultimatum," said the official, referring to a second ultimatum from el-Sissi that explicitly demanded Morsi find a solution with his opponents or the military would intervene.
Soon after the first deadline was issued, two Morsi aides called the commander of the 2nd Field Army, Maj. Gen. Ahmed Wasfi, based in the Suez Canal region, and sounded him out about installing him in el-Sissi's place, the military officials said. Wasfi immediately informed el-Sissi of the call, they said.
Seif el-Yazl and the military and intelligence officials said security in the strategic Sinai Peninsula bordering Gaza and Israel was at the heart of the differences. The region plunged into lawlessness after Mubarak's ouster, with Islamic militants gaining increasing power. Soon after Morsi took office, militants killed 16 Egyptian soldiers in a single attack and smaller-scale shootings on security forces mounted. In May, six policemen and a soldier were kidnapped.
Morsi in each case vowed action, but he and his aides also spoke publicly on the need for restraint and dialogue. At one point, he publicly acknowledged holding the military back from a raid to prevent civilian casualties, and he also spoke of the need not to harm the kidnappers as well as the captives. Morsi's ultraconservative Salafi allies mediated with militant groups to get them to halt violence, although attacks continued.
In November, Morsi ordered el-Sissi to halt a planned Sinai offensive a day before it was to be launched, and el-Sissi complied, Self el-Yazl said. In May, the kidnappers released their captives after a week, apparently after mediation. Morsi vowed publicly to track them down, but the military officials said the president ordered el-Sissi to pull his forces out of the area where they were believed to be. Again, the military complied. The kidnappers have not been caught.
The security and intelligence officials said they reported to Morsi about a rising number of foreign jihadis, including Palestinians, entering Sinai. The military identified Gazan militants involved in the killing of the 16 soldiers, but Morsi rejected a request by el-Sissi that he ask Hamas to hand them over for trial, the officials said. Hamas has repeatedly denied any role in the killings.
Morsi instead ordered el-Sissi to meet with Hamas leader Khaled Meshaal to discuss the issue. El-Sissi refused, because of the military's longtime view of Hamas as a threat, said the officials.
The military saw the policy of dialogue as being rooted in the Brotherhood's sympathy to others in the Islamist movement, even ones engaged in violence. Another incident deepened the military's belief that Morsi was more interested in a regional Islamist agenda than what the army saw as Egypt's interests.
During an April visit to Sudan, which has an Islamist government, Morsi showed flexibility over the fate of a border region claimed by both countries. After Morsi's return, el-Sissi sent his chief of staff to Khartoum to "make it crystal clear to the Sudanese that the Egyptian armed forces will never surrender" the territory, one defense official said.