He never believed the generals would turn on him as long as he respected their autonomy, Mr. Morsi’s advisers said. He had been the Muslim Brotherhood’s designated envoy for the group’s talks with the ruling military council after the ouster of Mr. Mubarak. And his counterpart on the council was Gen. Abdul-Fattah el-Sisi.

The Brotherhood was naturally suspicious of the military, its historical opponent, but General Sisi cultivated Mr. Morsi and other leaders, one of them said. “That is how the relationship between the two of them started,” said a senior Brotherhood official close to Mr. Morsi. “He trusted him.”

The two grew so close that Mr. Morsi caught his advisers by surprise when he promoted General Sisi last summer to defense minister as part of a deal that persuaded the military for the first time to let the president take full control of his government.

But during the fall protests charging the Brotherhood with monopolizing power, General Sisi first signaled that his departure from politics might not be so permanent. Without consulting Mr. Morsi, General Sisi publicly invited all the country’s political factions — from social democrats to ultraconservative sheiks — to a meeting to try to hammer out a compromise on a more inclusive government. Mr. Morsi quashed the idea, said a Morsi adviser.