The telltale signs of a coup in the making began to surface soon after Mubarak ordered the army out on the streets to restore order after days of deadly clashes between protesters and security forces in Cairo and much of the rest of the Arab nation.
"This is in fact the military taking over power," said political analyst Diaa Rashwan after Mubarak stepped down and left the reins of power to the armed forces. "It is direct involvement by the military in authority and to make Mubarak look like he has given up power."
Army troops backed by tanks and armored fighting vehicles were given a hero's welcome by the protesters angry over brutal treatment by the police. The goodwill was reciprocated when the military vowed not to use force against protesters, a move that set them apart from the much-hated police who operated with near impunity under Mubarak.
The generals adopted a go-slow approach, offering Egyptians carefully weighed hints that it was calling the shots. They issued statements describing the protesters' demands as "legitimate" and made halfhearted calls on the demonstrators to go home and allow normal life to resume.
Rather than quit the protests, the demonstrators turned out in ever greater numbers. Mubarak offered one concession after another, but they all fell short of the protesters' demands that he immediately leave.
The military was clearly torn between its loyalty to the regime and the millions of protesters. Mubarak is one of their own, a former air force commander and a hero of the 1973 Arab-Israeli war.
But as the president continued to defy the growing crowds and cling to power, the Egyptian army moved more definitively toward seizing control for the first time in some 60 years.
Thursday brought the surprise announcement that the armed forces' highest executive body, the Supreme Council of the Armed Forces, was in "permanent session" - meaning that it was on a war footing.
State TV showed Defense Minister Hussein Tantawi presiding over a table seating some two dozen stern faced generals in combat fatigues - but no sign of commander in chief Mubarak. His newly appointed vice president, former army general and intelligence chief Omar Suleiman, was not there either - indicating a rift between the civilian and military leadership.
A statement, tellingly referred to as "communique number 1" - phrasing that in the Arab world suggests a coup - made no mention of Mubarak or Suleiman.
The council, it said, met to "discuss what measures and arrangements could be taken to safeguard the homeland and its achievements and the aspirations of the great Egyptian people."
Translation: The generals are in charge, not Mubarak, not Suleiman nor the Cabinet.
The communique set the stage for what the crowds of demonstrators expected would be Mubarak's resignation Thursday night. Instead, Mubarak announced he would stay in office and hand over power to Suleiman, who told protesters to go home and stop watching foreign news reports.
The protesters were furious - and so were the generals.
"Both of last night's addresses by Mubarak and Suleiman were in defiance of the armed forces," Maj. Gen. Safwat el-Zayat, a former senior official of Egypt's General Intelligence, told al-Ahram Online, the Internet edition of Egypt's leading daily, on Friday.
Protest leaders pleaded for the military to take over after Mubarak's speech, saying the country would explode until the army intervened.
If Mubarak had stepped down, handing Suleiman his presidential powers in line with the constitution would have kept his regime largely intact after he had gone, something that would have left the protesters unhappy.
In contrast, a military coup would provide a clean break with a regime they hated for so long, opening up a wide range of possibilities - suspending the constitution that many protesters saw as tailored to keep Mubarak in office and dissolving a parliament formed by an election marred by widespread fraud. A coup seemed to be the best way forward.
The first official word the protesters received from the generals on Friday, however, was discouraging.
A second military communique contained what appeared to be a reluctant endorsement of Mubarak's blueprint for a way out of the crisis, though it also projected the military as the ultimate guarantor of the country's highest interests. El-Zayat said the language in the statement was an attempt to avoid an open conflict.
Later Friday, with millions out on the streets demanding that he step down, Mubarak finally did just that. He may have been denied the chance to announce his own departure - say goodbye to the people he had ruled for nearly 30 years. Suleiman announced the decision for him.
Alternatively, he may have not wanted to go on television to say he was stepping down after less than 24 hours after insisting to serve out the remaining seven months of his current term.
It was a humiliating end.
Keeping up appearances, The military later issued a third military statement praising Mubarak as a leader who has done much to his country. It hinted that the military would not be in power for long, saying the armed forces were not a substitute for a legitimate administration. But it gave no clue as to what its plans are.
"The truth is that even the senior military now at the top of the power structure under Mubarak almost certainly have no clear idea of what happens next," Anthony Cordesman of the Washington-based Center for Strategic and International Studies, wrote in a commentary on Thursday. "It will be days before anyone know how well the transition will function, who goes and who stays, and how stable the result really is."
Hendawi is the AP chief of bureau in Cairo.