CAIRO  President Hosni Mubarak of Egypt struggled to maintain a tenuous hold on power on Saturday as the police withdrew from the major cities and the military did nothing to hold back tens of thousands of demonstrators defying a curfew to call for an end to his nearly 30 years of authoritarian rule.

As street protests flared for a fifth day, Mr. Mubarak fired his cabinet and appointed Omar Suleiman, his right-hand man and the country’s intelligence chief, as vice president. Mr. Mubarak, who was vice president himself when he took power after the assassination of President Anwar el-Sadat, had until now steadfastly refused pressure to name any successor, so the move stirred speculation that he was planning to resign.

That, in turn, raised the prospect of an unpredictable handover of power in a country that is a pivotal American ally  a fear that administration officials say factored into President Obama’s calculus not to push for Mr. Mubarak’s resignation, at least for now.

The appointments of two former generals  Mr. Suleiman and Ahmed Shafik, who was named prime minister  also signaled the central role the armed forces will play in shaping the outcome of the unrest. But even though the military is widely popular with the public, there was no sign that the government shakeup would placate protesters, who added anti-Suleiman slogans to their demands.