SANAA Yemen's government and armed tribesmen demanding President Ali Abdullah Saleh leave power agreed on Saturday to end their confrontation which had brought the poor Arabian Peninsula country to the brink of civil war.
The deal included a withdrawal of armed tribesmen from government buildings and moves to normalise life in the Hasaba district of the capital Sanaa, scene of a week-long clashes that killed 115 people, a source close to mediators told Reuters.
A government official told Reuters: "Yes, we have an agreement which takes effect tomorrow (Sunday) morning."
A tribal official confirmed an agreement had been reached.
The fighting had prompted thousands of residents to flee Sanaa and raised the prospect of chaos that could benefit the Yemen-based branch of al Qaeda and threaten neighbouring Saudi Arabia, the world's biggest oil exporter.
The latest violence, pitting Saleh loyalist forces against members of the powerful Hashed tribe led by Sadeq al-Ahmar, was the bloodiest since pro-democracy unrest erupted in January and was sparked by Saleh's refusal to sign a power transfer deal.
Mediators will start taking over the occupied buildings from the al-Ahmar tribesmen on Sunday and hand them over to government forces, the mediators said.
In southern Yemen, three French aid workers went missing and a local security official said they were believed to have been abducted.
Kidnappings of Western tourists or workers by disgruntled tribes seeking ransom or concessions from the government have been frequent in Yemen. Most hostages have been freed unharmed.
A prominent think-tank, the International Crisis Group, said a broad, lasting ceasefire was needed immediately and should be part of a plan that leads to a transition of power.
"To prevent further escalation and loss of life, the most urgent step is for both sides to immediately accept a ceasefire mediated by Yemen's statesmen and tribal leaders," the ICG said in a "conflict risk alert" issued late on Friday.
Foreign states should be involved, it said, "but, given the deeply personal and tribal nature of the feud between the Salehs and al-Ahmars, it cannot be addressed effectively by international mediation or initiatives alone".
Global powers have little sway in Yemen, where tribal allegiances are the most powerful element in a volatile social fabric and the fighting already appears to be playing out along tribal, quasi-feudal lines.
The political crisis has already cost the economy as much as $5 billion and immediate aid is needed to prevent a meltdown in the country with a nominal GDP of $31 billion, the country's trade minister told Reuters.
"The economy should not be held hostage to the political crisis, because the situation is alarming," Hisham Sharaf Abdalla said.
On Friday, Yemeni tribesmen said they had captured a military compound from elite troops loyal to the president 100 km (60 miles) outside Sanaa, widening a conflict hitherto concentrated mainly in the capital near the home of Ahmar.
The fighting has overshadowed a largely peaceful protest movement that started months ago aimed at ending Saleh's 33-year-long autocratic rule and inspired by uprisings that brought down the long-standing leaders of Tunisia and Egypt.
Mediators have become exasperated with Saleh, saying he had repeatedly imposed new conditions each time a Gulf-led transition agreement was due for signing, most recently demanding a public signing ceremony.
Machinegun fire and explosions rattled Sanaa this week before clashes eased after mediation efforts. Ahmar's fighters evacuated government ministry buildings they had grabbed in return for a ceasefire and troops quitting their area.
There was also an informal truce prevailing in a region northeast of Sanaa where tribes said on Friday said they had seized a military post.
Yemeni air force fighters had strafed those tribal fighters with bombs and broke the sound barrier in flights over Sanaa.
There are worries that impoverished Yemen, where some 40 percent of the country's 23 million people live on less than $2 a day, could become a failed state located on a shipping lane through which 3 million barrels of oil pass daily.
In the south, dozens of armed men believed to be from al Qaeda appeared to have full control of city of Zinjibar in the flashpoint province of Abyan on Saturday, a day after storming the city and chasing out security forces, residents said.
The opposition coalition accused the government in a statement of allowing towns to be taken over by groups "set up and armed by the regime to act as scarecrows to frighten local, regional and international parties".
The United States and Saudi Arabia, both targets of foiled attacks by the Yemen wing of al Qaeda, are concerned any spread of anarchy could embolden the militant group.
With the political strife, the Yemen-based al Qaeda in the Arabian Peninsula (AQAP) is likely to have more freedom to use a proven talent for daring bombing plots, analysts said.
"Given how distracted Saleh's government is in its attempts to cling to power, AQAP has much more open space in which to operate at the moment," said Yemen scholar Gregory Johnsen.
(Additional reporting by Mohammed Ghobari in Sanaa, Mohammed Mukhashaf in Aden, William Maclean in London and Helen Massy-Beresford in Paris; Writing by Jon Herskovitz and Firouz Sedarat in Dubai; Editing by Louise Ireland)