SANAA Yemeni President Ali Abdullah Saleh has overcome a myriad of challenges to his nearly 33 years as leader of an unruly and poor country that has endured civil war, uprisings and militant campaigns.
Yemen, which has seen steadily intensifying street protests against Saleh's rule since January, edged perilously close to civil war this week as forces of the Hashed tribal group clashed with troops loyal to Saleh in the capital and elsewhere.
He once described running the fractious mountainous country of 23 million at the tip of the Arabian Peninsula as akin to "dancing on the heads of snakes."
But with opposition to his rule mounting from all corners over the past year, Saleh's dancing days appeared to be almost over.
"I will stay in Yemen. I will preside over my party and I will be in the opposition. I will lead the political process... and will be a partner in power," he told Reuters recently.
Yet he remains in office, clinging to a power base that effectively only extends to the borders of the capital of Sanaa.
The United States has talked openly of its concern about who might succeed Saleh, an ally in the fight against Al Qaeda in the Arabian Peninsula, a Yemen-based wing of the militant group.
Last year, supporters were pushing for constitutional changes to allow Saleh unlimited five-year terms as president and speculation was high that he was grooming one of his sons as a possible successor.
But a popular uprising that began in distant Tunisia in December came to scupper the plans, which Saleh's Western and Arab backers had been expected to endorse, given their fears of the growing al Qaeda threat in Yemen.
After Tunisian President Zine al-Abidine Ben Ali fled on January 14, Egyptians began their own uprising that led to Hosni Mubarak's resignation as president on February 11.
By then, tens of thousands of Yemenis had begun daily protests outside Sanaa University and Saleh had begun to offer verbal concessions.
First he said he would not stand for re-election in 2013 and dismissed the idea of his son succeeding.
In March, when the opposition had gathered more momentum, winning the backing of tribal leaders, Saleh offered a referendum on a new constitution by the end of the year and a shift to a truly democratic "parliamentary system."
He continued to reject the street calls for a handover of power this year.
But the death of 52 protesters mostly hit by sniper fire in Sanaa on March 18 proved to be a turning point, prompting a string of generals, tribal leaders, diplomats and ministers to resign or declare their public allegiance to the protesters.
Many were from the al-Ahmar and Sanhan tribes, kinsmen whom Saleh placed in key military and other positions, skewing state building in a tribal society and stirring resentment among ordinary people in one of the world's poorest nations.
Saleh appeared to realize the gravity of the bloodshed, sacking his cabinet and declaring a 30-day state of emergency. But he continued to stall in negotiating a transition of power.
Since then, he has come tantalizingly close three times to signing a power transfer deal brokered by Gulf Arab states, only to slip out of it at the last moment, prolonging the standoff.
Opponents often complained that Yemen under Saleh failed to meet the basic needs of the country's people, where two of every three live on less than $2 per day. Oil wealth is dwindling and water is running out, though liquid natural gas exports began in 2009.
Yet Saleh managed to keep Western and Arab powers on side.
After the September 11, 2001 attacks against U.S. cities, Yemen came on to Washington's radar as a source of foot soldiers for Osama bin Laden's al Qaeda network. Bin Laden himself, though born in Saudi Arabia, originated from Yemen's Hadramaut region.
Saleh cooperated with U.S. authorities, and the CIA carried out a successful drone attack against a wanted figure. But by 2007, militants had regrouped in Yemen and in 2008 they announced that their Saudi and Yemeni wings had united under the banner of Al Qaeda in the Arabian Peninsula.
From 2009, the resurgent group made ever bolder attempts to stage attacks on Saudi and U.S. targets beyond Yemeni soil, as well as targeting foreign tourists at home. At the same time, northern Shi'ites rebelled against Saleh's rule and southerners, feeling marginalized, began a new separatist drive.
Saudi Arabia, the United States and other allies responded by stepping up with financial support to bolster Saleh's rule.
If Saleh has been a determined survivor, he has also been a charismatic and often popular ruler who understood well the workings of Yemeni society.
Born in 1942 near Sanaa, he received only limited education before joining the military as a non-commissioned officer.
His first break came when President Ahmed al-Ghashmi, who came from the same Hashed tribe as Saleh, appointed him military governor of Taiz, North Yemen's second city. When Ghashmi was killed by a bomb in 1978, Saleh replaced him.
In 1990, an array of domestic and regional circumstances propelled North Yemen under Saleh and the socialist South Yemen state into a unification that Saudi Arabia at first opposed.
He angered Riyadh by staying close to Saddam Hussein during the 1990-1 Iraqi occupation of Kuwait, leading to the expulsion of up to 1 million Yemenis from Saudi Arabia. Before the crisis, Kuwait had given Yemen financial aid.
But Saleh then won plaudits from Western powers for carrying out economic reforms drawn up by the International Monetary Fund and World Bank, and made efforts to attract foreign investors.
He swept to victory when southerners tried to secede from united Yemen in 1994 and drew closer to Saudi Arabia, which he allowed to spread its radical Wahhabi form of Sunni Islam.
(Writing by Andrew Hammond; Editing by Reed Stevenson)