RIYADH (Reuters) - Yemeni President Ali Abdullah Saleh signed a deal on Wednesday under which he will step down after 33 years in power and 10 months of protests against his rule that brought the country to the brink of civil war.
Celebrations erupted in the capital Sanaa as Saleh inked the agreement that made him the fourth leader to be forced from power in 10 months of mass protests that have swept the Arab world. Yemenis danced in the streets, set off fireworks and waved flags as Saleh finally agreed to step down.
Under the agreement, signed with opposition leaders at a ceremony hosted by Saudi King Abdullah at the royal palace in Riyadh, Saleh will immediately transfer his powers to his deputy, Abd-Rabbu Mansour Hadi. In return he will retain the title of president until a new head of state is elected.
"I declare the turning of a new page in the history of Yemen," Saudi King Abdullah said in a brief statement before the signing ceremony, also attended by Crown Prince Nayef.
"Saudi Arabia will remain the best supporter for Yemen," the king added.
Hadi would form a new government with the opposition and call an early presidential election within three months.
"This is as honorable an exit as he (Saleh) can get, considering the circumstances," said Ghanem Nusseibeh, a London-based analyst. "But the key thing is how the deal will be implemented and if the coalition government will be strong enough to take charge of the whole country," he added.
The United States and the European Union hailed the accord.
"This represents an important step forward for the Yemeni people, who deserve the opportunity to determine their own future," President Barack Obama said in a statement.
The Pentagon said the United States and Yemen would continue to work together against militants. "Despite the political instability in Yemen, we have been able to preserve important counter-terrorism relationships with that country."
In Brussels, EU foreign policy chief Catherine Ashton said Saleh's signing of the deal should open the way to national reconciliation and a transition to democracy.
"The agreement is only the beginning, but it is a very important beginning. It allows the Yemeni people the much needed hope that their country can turn a page in its history and embrace a new future," she said in a statement.
Saudi state television broadcast live the signing ceremony, where Saleh was shown chatting and sipping traditional coffee with King Abdullah. Saleh spent three months in Riyadh undergoing treatment following an assassination attempt in June.
The attempt on Saleh's life came after he ducked out of the deal, which ushered in street battles that devastated parts of his capital Sanaa.
The 69-year-old leader, who has ruled Yemen since 1978, asked Saudi Arabia and members of the U.N. Security Council to ensure the implementation of the accord, brokered by Yemen's Gulf Arab neighbors.
"We aspire with confidence to the brothers in Saudi Arabia ... to review, help and oversee the implementation of the accord and the operational mechanism," he said.
Hundreds of people have been killed during months of protests seeking Saleh's ouster. The political deadlock has reignited simmering conflicts with separatists and militants, raising fears that Yemen's al Qaeda wing could take a foothold on the borders of Saudi Arabia, the world's top oil exporter.
Details of the power transfer deal -- drawn up by Yemen's richer neighbors in the six-member Gulf Cooperation Council (GCC) earlier this year, and thwarted by Saleh on three separate occasions -- were hammered out by U.N. envoy Jamal Benomar, with support from U.S. and European diplomats.
"This is a very good day for Yemen and we hope it provides the framework for a reform process during the transition that will lead to...free and fair elections," he told Reuters at the signing ceremony.
U.N. Secretary-General Ban Ki-moon told reporters in New York that Saleh had told him in a telephone conversation on Tuesday that he intended to "come to New York to take medical treatment immediately after signing this agreement."
A Yemeni official had said on Tuesday that the accord was facing opposition from some senior politicians in Saleh's General People's Congress (GPC).
Saudi fears about chaos in Yemen are shared by Washington, which regards the country as a front line against al Qaeda and long backed Saleh as a key to its campaign against Islamist militants.
The deal to nudge him from power was denounced by some of the youth protesters who have emerged as a presence in Yemen's politics, and regard the parties that negotiated his exit partners in the crimes of which they accuse Saleh.
"We will remain on the streets until our demands are met," activist Samia al-Aghbari told Reuters. "Saleh's crimes won't end with time, so we will pursue him and all the killers."
But others welcomed the deal as a first victory of their uprising.
"This is a great victory," Badr Ali Ahmed, an activist at Change Square, said. "We have achieved one of the goals of the revolution, which is to bring down the head of the regime, and God willing we will achieve the rest."
Hamdan al-Haqab, a field organizer, said: "We were not part of this initiative, but since it happened, we consider it to be the first achievement of the revolution ... We will continue to achieve all our goals."
A Yemeni official said that renegade general Ali Mohsen, a longtime Saleh ally who turned on him after protests began, and Sadeq al-Ahmar, a tribal notable who also threw his weight against Saleh, could try to block the deal which excludes them.
Those figures, along with Saleh's son and a nephew who commands a key paramilitary unit, form a balance of forces on the ground that analysts say none is likely to tip, making a political resolution the only way out of Yemen's deadlock.
Witnesses said Ahmar fighters and Saleh forces traded shelling in the Soufan and al-Hasaba neighborhoods in Sanaa, where the tribal chief lives, and that sounds of explosions could be heard from a distance.
There were no reports of casualties. The area was the scene of heavy clashes earlier this year, where scores of people from both sides died.
Additional reporting by Mohammed Ghobari in Sanaa; Writing by Sami Aboudi; Editing by Samia Nakhoul and Giles Elgood