(REUTERS) - Yemeni President Ali Abdullah Saleh signed a deal on Wednesday under which he stepped down from 33 years in power and 10 months of protests against his rule that have brought the country to the edge of civil war.
Celebrations erupted in Yemen as Saleh signed the deal which made him the fourth leader to be forced from power following the Arab Spring's 10 months of mass protests. Yemenis voiced joy and exhilaration, dancing in the streets and waving flags.
Under the agreement, signed with the Yemeni opposition at a ceremony hosted by Saudi King Abdullah in the capital Riyadh, Saleh transferred his powers to his deputy, Abd-Rabbu Mansour Hadi, ahead of an early election. In return he will receive immunity from prosecution.
Hadi is to form a new government with the opposition and call an early presidential election within three months. Saleh will keep his title until a successor is elected.
I declare the turning of a new page in the history of Yemen, said Saudi King Abdullah in a brief statement before the signing ceremony, also attended by Crown Prince Nayef.
Saudi Arabia will remain the best supporter for Yemen, the Saudi king added.
Present at the signing ceremony were senior members of the Saudi royal family as well as foreign diplomats.
Saudi state television broadcast live the signing ceremony, held in the royal palace in Riyadh, where Saleh was forced to seek treatment after an assassination attempt in June.
The attempt on his 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.
MONTHS OF BLOODSTAINED PROTESTS
Hundreds of people have been killed during months of protests seeking Saleh's overthrow. 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.
U.N. Secretary-General Ban Ki-moon told reporters in New York that Saleh 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.
The accord gives the vice president the power to implement the Gulf initiative, Benomar told a news conference in Sanaa before he boarded a plane to Riyadh along with Yemeni government officials and opposition leaders to attend the signing ceremony.
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, and both long backed Saleh in their campaign against al Qaeda.
PROTESTERS DENOUNCE DEAL WITHIN THE REGIME
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.
This agreement comes from within inside the regime, said Abdul Rahim, a 27-year-old English teacher and human rights activist. It does not address our demands, he added.
We were not part of this initiative, but since it happened, we consider it to be the first achievement of the revolution, said Hamdan al-Haqab, a field organizer. We will continue to achieve all our goals.
A Yemeni official said 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 Jon Hemming)