RIYADH, Saudi Arabia — Faced with unrelenting popular demands that he relinquish control of a country he ruled for almost 30 years, a defeated Hosni Mubarak quit the presidency of Egypt, ushering both his country and the wider Arab world into a new, uncertain era imbued with the hopes of millions for more democracy, less fear and greater opportunities.

The 82-year-old leader’s resignation came on the 18th day of unprecedented street protests and demonstrations by Egyptians from all walks of life demanding that he leave office as the first step in a process of political and economic reform.

It also followed growing momentum from the protest campaign, which had engulfed several major cities and drawn in labor unions as well as figures from the state-run media.

Mubarak is the second Arab leader forced from office by popular protests. Tunisia’s President Zine El Abidine Ben Ali fled his country on Jan. 14.

The most pivotal character in Egypt’s tumultuous rebellion was always the army. It remained unclear last night what actions — if any — the military had taken to convince Mubarak to step down.

Significantly the country’s top military leadership declared that it was convening in special session to consider moves “to protect the nation” just hours before Mubarak addressed the nation Thursday night and said that he intended to stay in power until September.

Mubarak's stubborn speech and the one that followed by Vice President Omar Suleiman enraged the crowds and did not stop the demonstrations.

But Friday when it was announced that Mubarak had stepped down and turned power over to the military, the popular mood immediately shifted to jubilation. In Cairo’s Tahrir Square, the epicenter of the mostly peaceful revolution, thousands of protesters waved flags, danced and sang, delirious at reaching their goal of forcing Mubarak from office.

Mubarak had led Egypt since the 1981 assassination of his predecessor Anwar Sadat.

Egypt’s historic drama has mesmerized the Arab world for more than two weeks, with people across the region glued to their televisions, laptops and phones for up-to-the-minute news.

Ordinary citizens, many of whom live under authoritarian governments kept in place by feared security police forces, are enthralled with the promise of change they believe will undulate out of Egypt across their region.

“Everybody is excited,” said Zuhair al Ghamdi, 45, an assistant manager in information technology at Saudi Arabia Airlines. “Here, people never cared about the news, they didn’t watch TV. They were not interested in seeing dead bodies in Iraq. But after the revolution, we are watching around the clock. Morning, afternoon and night, up to 2 o’clock.”

The reaction has been very different in the plushly carpeted, chandeliered palaces of Arab presidents and kings, who are mostly unelected.

Saudi Arabia’s King Abdullah bin Abdul Aziz, who is in Morocco recuperating from back surgery, had been outspoken in his support for Mubarak. In a Jan. 29 phone call with U.S. President Barack Obama, the king declared that there could be “no compromise” on Egypt’s stability and security, the official Saudi news agency reported.

The agency went on to say that “the tragic events” in Egypt were marked by “chaos, looting, intimidation of innocents, exploitation of freedom and expression, and attempts to ignite the flames of chaos to achieve their suspicious goals ... not approved by Saudi-U.S. sides.”

The Times of London reported that King Abdullah had also warned the U.S. president not to “humiliate” an Arab leader who had been a faithful ally of Washington for decades. The paper also reported that the Saudi monarch said he would replace the $1.5 billion in annual aid that Washington gives Egypt if it were cut.

The two leaders had another phone conversation about Egypt on Feb. 9, the White House said.

It is easy to explain the Saudi leadership’s unease. Egypt under Mubarak has been a pillar, along with Riyadh, of the U.S.-led regional order in the Middle East. The two Arab countries have worked closely on many fronts, including countering Iran’s hegemonic attempts to interfere in Arab affairs.

Now, Saudi Arabia has no way of knowing what kind of future cooperation it will get from Egypt. Even if its foreign policy remains much the same, it may not carry much weight if the country becomes ensnared in internal problems.

“The Saudis were caught completely off-guard,” said Theodore Karasik, director of research at the Dubai-based Institute for Near East and Gulf Military Analysis (INEGMA). “Now it has to reformulate its foreign policy based on the future path of this catharsis in Egypt.”

Asaad Al Shamlan, assistant professor of political science at Riyadh’s Institute of Diplomatic Studies, said that “a more democratic Egypt will mean a more scrutinized foreign policy from inside” and thus “different calculations will come.”

The other concern of Saudi Arabia and its Gulf neighbors relates to their domestic affairs.

Although they are mostly wealthy states that can placate their citizenry with social services and financial benefits, there are calls for democratic reforms, such as having elected parliaments.

How much Egypt’s revolution will affect other Gulf states domestically remains to be seen.

All that is certain, Al Shamlan said, is that “things are changing in a way that was unanticipated and unprepared for.”