Rival groups in Yemen have signed a UN-brokered peace deal after Shiite rebels seized the government headquarters and the prime minister resigned following raging violence in the capital.
"A national peace and partnership agreement based on the outcomes of the national dialogue conference was signed this evening at the presidential palace" in Sanaa, state news agency Saba reported Sunday.
President Abdrabuh Mansur Hadi, United Nations envoy Jamal Benomar and representatives of Yemen's political forces, including the Shiite rebels, attended the signing ceremony, it said.
"We have reached a final deal with which we can overcome this crisis," Hadi said in a speech.
Benomar said the agreement calls for the formation of a new government within one month.
Under the deal, Hadi will also appoint advisers from the Shiite Ansarullah rebels and southern separatists within three days, Benomar said at the signing ceremony broadcast on state television.
A new premier to replace Mohamed Basindawa will be named by Hadi, also within three days, and must be "neutral and not belonging to any party", according to the agreement read by Benomar.
Two representatives of rebel leader Abdulmalik al-Huthi signed on behalf of the insurgents, said an AFP journalist who attended the ceremony.
The rebels earlier Sunday swooped on key institutions across Sanaa, including the government headquarters and military sites, after an apparent surrender by security forces.
Under the accord, the rebels must hand over institutions they have seized, dismantle protest camps they set up in and around Sanaa more than a month ago, and "immediately end all acts of violence".
After the deal was signed, Saba reported that the rebels began withdrawing from government buildings in a handover overseen by Defence Minister General Mohammed Nasser Ahmed.
UN chief Ban Ki-moon said the agreement marked a "positive step towards political stability and peace in the country", according to a statement issued by his spokesman.
Ban also "expected that the agreement will be implemented in full without delay".
- Rebels sweep in -
In a resignation letter, Basindawa accused Hadi of being "autocratic", according to the text of the letter released by the council of ministers.
Signup to our newsletter and follow us on Facebook and Twitter!
"The partnership between myself and the president in leading the country only lasted for a short period, before it was replaced by autocracy to the extent that the government and I no longer knew anything about the military and security situation," he wrote.
His resignation had come as rebels overran state radio, the general command of the armed forces, headquarters of the sixth military region, the fourth brigade and the defence ministry's media arm, official and rebel sources said.
They swept into the parliament building and took over the central bank and civil aviation authority, the sources said.
The interior ministry's website urged security forces not to confront the insurgents.
Interior Minister Abdo al-Tarib instead urged "cooperation" with the rebels "to strengthen security and stability, preserve public property and guard government installations... and to consider Ansarullah friends of the police."
The rebels had advanced into Sanaa from their mountain stronghold in the far north last month and set up armed protest camps to press their demands for political change.
Their offensive had been denounced by Hadi on Friday as a "coup attempt".
Sunday's developments came a day after the UN announced a power-sharing deal to end a week of fighting between the rebels and pro-government forces which had left dozens dead on both sides and forced the suspension of all flights into and out of Sanaa airport.
- Exodus of terrified residents -
Saba reported late Sunday that Hadi was meeting Yemeni political forces, including representatives of Ansarullah.
After consulting his newly appointed advisers, Hadi is expected to name the ministers of defence, interior, foreign affairs and finance.
The new premier will choose the remaining ministers from among candidates presented to him from the various political parties.
Hadi had already agreed to bring the rebels into a new government to replace the unpopular administration that imposed austerity measures, including a fuel price hike, earlier this year.
The rebels have demanded posts in key state institutions as part of their push for greater political clout.
Yemen has been swept by political turmoil since longtime strongman Ali Abdullah Saleh was forced from the presidency in early 2012.
The rebels hail from the Zaidi Shiite community, that makes up 30 percent of Yemen's mostly Sunni nation but the majority community in the northern highlands, including the Sanaa region.
They have battled the government on and off for a decade from their stronghold of Saada in the far north.