| Saleh has ruled Yemen for 33 years despite CIA's initial prediction he will not last more than six months [EPA]
Ali Abdullah Saleh, Yemen's president, has signed a deal in the Saudi capital, Riyah in which he will step down after months of unrest.
Saleh took over the presidency of North Yemen in 1978, and became president of Yemen after its two halves were united in 1990. The only man to ever serve as president of the unified Republic of Yemen, he proved to be a wily political operator, manipulating Yemen's tribal system and fending off sustained insurrections in the north and south.
He often portrayed himself as the only man who could hold together a united Yemen. In February, in the early days of the months-long popular campaign to drive him from office, Saleh portrayed the opposition as a conspiracy to destroy the country - a theme he has struck often during his decades in power.
"There is a conspiracy against Yemen's unity and territorial integrity," he told a group of senior military officers. "We have served to preserve the republican regime with every drop of blood we have."
But his reign was also defined by charges of corruption and mismanagement: Yemen is one of the poorest countries in the world, with widespread unemployment and persistent inflation; and billions of dollars in oil revenues have been embezzled or wasted. 40 per cent of Yemen's population lives on less than $2 per day.
No negotiated exit
Saleh's failures as president fuelled months of popular protests which began in January, shortly after the ouster of Tunisian president Zine El Abidine Ben Ali. Protesters have spent months camped in front of Sanaa University, where they erected tents and chanted for his resignation. Demonstrations also spread to several other Yemeni cities, with the southern city of Taiz emerging as an epicentre: Turnout at some rallies reached hundreds of thousands of people.
Rights groups say more than 350 people have been killed since Yemen's uprising began [Reuters]
The protests were at first led by students and young people, but they eventually grew to include much of Yemen's fractious opposition. The Houthis, Shia rebels in the north who have fought a long-running war with Sanaa, endorsed the protest movement; so did the Southern Movement, the secessionist group in the south.
Several high-ranking military officers deserted Saleh after a particularly brutal crackdown on March 18, when at least 50 protesters in Sanaa were killed by snipers. General Ali Mohsen Saleh was the first to go: He ordered the troops under his command to protect protesters.
The protests also emboldened the Ahmar family, fellow members of Saleh's Hashed tribal confederation who have emerged as his chief political opponents. Hamid al-Ahmar, a prominent businessman, is seen as a possible successor to Saleh; his brother, Hussein al-Ahmar, quit the ruling party in February and publicly rebuked Saleh.
Fighting between Saleh and the Ahmar family has paralysed the capital for weeks. Fighters loyal to Saleh shelled the Ahmar compound in Sanaa and several businesses owned by the family; al-Ahmar's men have been blamed for the rocket attack against the presidential palace , though the government has yet to prove that allegation.
Saleh tried to negotiate his way out of the protests, offering to form a "unity government" and proposing a committee to overhaul the constitution. Opposition groups dismissed Saleh's offer as a "waste of time."
Weeks later, he went a little further, offering to step down by the end of the year and promising to hand power to a civilian government. The opposition rejected that offer, too, holding out for a more immediate resignation.
The president also tried to buy his way out of trouble, offering tens of thousands of dollars (and new cars) to groups of tribal elders. But his tribal support, which constitutes his main power base, has been eroding for weeks.
Neighbouring countries tried to broker a peaceful exit for Saleh: A proposal negotiated by the Gulf Cooperation Council would have granted Saleh immunity from prosecution in exchange for stepping down. But he refused - on three different occasions - to sign the deal.
Saleh was born in 1946 in the town of Bayt al-Ahmar, a member of the Sanhan tribe, a small member of the Hashed tribal confederation. His early career was spent in the military; he fought for the republican government in North Yemen's civil war, which pitted the Saudi-backed remnants of the monarchy against the Egyptian-sponsored republicans.
He would remain in the army until 1978, when he made a move into politics: He took power after the president was assassinated, and never relinquished the post.
Expectations for his presidency were low: An estimate from the US Central Intelligence Agency predicted that he wouldn't last six months in office. But he held on, consolidating power within the ruling General People's Congress (GPC) and buying the support of the country's fractious tribes. He was re-elected in 1982, and again in 1988.
Saleh then presided over the unification of north Yemen with the Communist south, which lost its main patron when the Soviet Union collapsed. The marriage quickly soured, though, with the south frustrated by what it saw as its economic marginalisation at the hands of the northern-dominated government.
Civil war broke out in mid-1994, and the south seceded in May of that year. Its separation would last only two months, though, before its military was crushed by the north, placing Saleh once again at the helm of a unified Yemen.
Saleh was an ally of former Iraqi strongman Saddam Hussein, and his decision to back Iraq during the first Gulf War would have serious consequences for Yemen's economy: Saudi Arabia responded by expelling more than a million Yemeni workers from the kingdom, depriving countless Yemeni families of vital remittances.
After the September 11 attacks, Saleh tried to position himself as a vital ally to the United States. He made an official visit to Washington in 2007, where he met with then-president George Bush at the White House. And he allowed American drone aircraft to kill alleged al-Qaeda targets on Yemeni soil. Yemen, in return, has been the recipient of tens of millions of dollars in American aid.
A questionable legacy
Saleh will tranfer power to his deputy ahead of an early election, and in return he would get immunity from prosecution.
He leaves behind a government that seems ill-equipped to handle the set of interlocking challenges confronting Yemen, including dwindling oil and water reserves and a rapidly growing population of unemployed youth.
His government is generally ranked as one of the most corrupt in the world. "A system of grand corruption has emerged over the last several decades thriving on the combination of weak state institutions and a fragmented elite structure," the US embassy in Sanaa said in a 2010 report. "Allies are rewarded and other elites pacified by grand patronage payoffs in exchange for political quiescence."
But Saleh's patronage network began to shrink as Yemen's oil reserves began to dry up. The country's oil production peaked in 2001, and has been declining ever since; some of the tribal unrest Saleh faced in recent weeks owes to his inability to "spread the wealth" as he once did.
He also failed to resolve ongoing conflicts with both the Houthis and the Southern Movement. The southerners have temporarily dropped their demand for secession - calling instead only for Saleh's ouster - but their longstanding economic grievances remain unaddressed.