Hours after Yemen’s president flew to Saudi Arabia for treatment of wounds sustained in a rocket attack, thousands of demonstrators flocked to the streets of the capital Sunday to celebrate what they billed as the latest ouster of an Arab autocrat.

“The Yemeni people have been born again,” cried out Fatima Ahmad, 72, who was among those who walked to Change Square in Sanaa to celebrate the departure of President Ali Abdullah Saleh.

Thousands waved flags, painted their faces with the colors of the national flag and exchanged congratulations in a capital that had become a battleground in recent days.

“We have deported Ali,” some chanted. “The people have toppled the regime.”

Saleh transferred power temporarily to his vice president, Abed Rabbo Mansour Hadi, after boarding a flight to Saudi Arabia late Saturday. He was wounded in a rocket attack on the presidential palace Friday afternoon.

The vice president met Sunday with U.S. Ambassador Gerald M. Feierstein, Yemen’s news agency reported. The two discussed steps required to maintain a cease-fire between government forces and tribal militias. They also spoke about Yemen’s the political opposition, known as the Joint Meeting Parties.

Yemeni officials have not called Saleh’s departure an abdication from power, but analysts say the longtime leader, who had been a key U.S. ally in the fight against al-Qaeda, is unlikely to return as president.

Despite the jubilation in Sanaa, bloodshed continued in the southern city of Taiz, where gunmen attacked the presidential palace, killing four soldiers, the Associated Press reported.

Saleh’s sudden departure comes as the country is on the verge of civil war and economic collapse, with a violent power struggle among rival tribesmen underway and no clear plan for a transition of power if Saleh were to permanently surrender office.

For months, Saleh had resisted intense pressure from within Yemen, the Middle East’s poorest nation, and from neighboring countries and the United States to step down. With an active al-Qaeda branch in Yemen — one ambitious enough to claim the mantle of Osama bin Laden in the near future — Saleh’s departure could pose one of the most significant policy challenges for the Obama administration in the months ahead.

A Pentagon spokesman acknowledged late Saturday that the crisis in Yemen was already affecting U.S. efforts to fight terrorism.

“The current protracted political issues are having an adverse impact on the security situation in Yemen,” said Col. David Lapan, a Pentagon spokesman, and the United States is “continuing to review and assess all aspects of our security assistance.”

But he indicated that Washington was already looking beyond Saleh’s rule. “Our shared interest with the Yemeni government in defeating al-Qaeda goes beyond one person,” Lapan said. The U.S. military has an unspecified number of counterterrorism trainers in Yemen, who the Pentagon has said remain in the country, although the civil unrest had affected their work.

In Sanaa, the Yemeni capital, an official in the president’s office confirmed that Saleh had left the country for Saudi Arabia and said that his vice president had taken over his duties. The White House said President Obama’s counterterrorism adviser, John Brennan, spoke with Hadi by telephone Saturday but provided no details, news services reported.

The AP quoted the state-run Saudi Press Agency as reporting that Saleh had arrived in the country.

Most of Saleh’s family accompanied him on the flight to Saudi Arabia, AP reported, citing a government official. But Saleh’s son Ahmed, whom he was grooming as a successor, was believed to have stayed behind, AP reported.

Christopher Boucek, an analyst with the Carnegie Endowment for International Peace, said violence in Yemen could become even more intense, given the animosity between Saleh’s supporters and those of the Ahmar clan, whose tribesmen have spearheaded the effort to topple Saleh.

“His son and nephews may try to finish off the Ahmars,” Boucek said. “The regime’s power lies in the military and security branches, the guys who have been fighting, and where do they go? They may think their only option is to fight.”

Gregory Johnsen, a Yemen expert at Princeton University, agreed that the next steps are unclear. “What happens with his family? Do his forces crumble? Who steps in to fill any vacuum?’’ Johnsen said. “At this point, there is no road map or someone very obvious waiting in the wings.”

Saleh’s departure fuel­ed speculation that the injuries he suffered in Friday’s midday attack — when a rocket or mortar shell struck a mosque inside the sprawling compound where Saleh and other senior officials were praying — could have been more serious than the palace has suggested.

Yemen’s state news agency reported Saturday that the country’s prime minister, Ali Mujawar, and the speaker of parliament, Yahya al-Raee, were among a handful of dignitaries flown to Saudi Arabia for medical treatment. Saleh was wounded in the head and was being treated at the Defense Ministry hospital, a Yemeni official said, speaking on the condition of anonymity to discuss the president’s medical state.

A few hours after the attack, Saleh delivered an audio address, but his voice seemed slow and slurred. He blamed the attack on the Ahmar family.

Afterward, government loyalists attacked the compound of Hamid al-Ahmar, a wealthy tycoon who has long opposed Saleh. That attack killed 19 people and wounded 40, tribal leaders said.

The clashes prompted Saudi Arabia’s King Abdullah to broker a temporary cease-fire between government forces and the Ahmar tribesmen. The kingdom, which neighbors Yemen, has long been worried about its poorer neighbor’s political instability and its abundance of al-Qaeda operatives, many of whom have links to Saudi Arabia. For decades, Saudi Arabia has played a role in shaping Yemen’s politics, and the kingdom could play a significant role in shaping Yemen’s future.

As evidence of the Saudi influence, the capital, Sanaa, and other parts of the country remained quiet and peaceful Saturday — after two weeks of mayhem.

Saleh’s ability to rule Yemen — which he has controlled for 33 years — has diminished significantly since a populist nonviolent uprising, inspired by similar rebellions in Tunisia and Egypt, was launched in January. Islamic militants, including al-Qaeda operatives, have taken control over some areas in Yemen’s restive south as government forces have left their positions. The economy is spiraling.

Joint U.S.-Yemen operations have ground to a halt in recent months as Saleh’s focus shifted to maintaining control of the country.

U.S. intelligence and counterterrorism officials have testified repeatedly that al-Qaeda in the Arabian Peninsula, as the Yemen branch is known, represents the most immediate threat to American interests. AQAP has been linked to a series of failed plots, including the attempted bombing of a Detroit-bound airliner on Christmas in 2009 and the shipment of printer cartridges packed with explosives to the United States.

The main worry among U.S. counterterrorism experts is that Saleh’s departure could set off a prolonged power struggle involving the few functioning institutions in Yemen: its military, intelligence services and tribal leadership. Those institutions, led by Saleh relatives and loyalists, were struggling to contain AQAP even before the dictator faced mounting protests against his rule.

“Once he steps out of Yemen, there’s a major question as to whether he ever returns,” said Juan Zarate, who was counterterrorism adviser to former president George W. Bush. “If in fact he leaves, I’m very pessimistic as to what follows. I think it turns very messy very quickly, creating all sorts of breathing space for [al-Qaeda] and problems for the United States.’’

“It’s a very dangerous elixir in Yemen,” Zarate added. Given the demise of bin Laden and other al-Qaeda figures, AQAP is positioned “to emerge as . . . the strategic driver for the jihadi movement.”

Johnsen said the United States might have to scramble to plan for the loss of an ally — albeit an inconsistent one — against AQAP.

“The U.S., until very recently, didn’t put much focus on what comes after Saleh,” he said. “I’m not sure they have a good plan for what comes next — assuming anyone can know what comes next.”

Raghavan reported from Nairobi. Staff writers Peter Finn, Greg Miller, Joby Warrick and Craig Whitlock in Washington and a special correspondent in Sanaa contributed to this report.