SANAA, Yemen -- Ali Abdullah Saleh survived for decades as Yemen's strongman, the master of shifting alliances, playing both sides - or flipping sides freely - in the multiple guerrilla conflicts and civil wars that tore apart his impoverished nation throughout his life. But his last switch proved to be his end.

Saleh, who was Yemen's president for 33 years until he stepped down in 2012 amid an Arab Spring uprising, was killed Monday by the Shiite rebels known as Houthis whom he'd once allied with in hopes of a return to power but then turned against in recent months.

A video circulating online showed Saleh's body, his eyes open but glassy, motionless, blood staining his shirt and a gaping wound In his head. He was being carried in a blanket by rebel fighters chanting "God is great" who then dump him into a pickup truck. His grisly end recalled that of his contemporary, Libya's Muammar Qaddafi, whose body was shown being abused by the rebels who killed him in that country's 2011 civil war.

Get Breaking News Delivered to Your Inbox

During his rule, Saleh was known as the man who "dances on the heads of snakes" for his ability to manipulate friends and enemies alike, using patronage, family bonds and brute force. That skill enabled him to stay on top in the Arab world's poorest nation and one of its most unstable, where tribal and regional alliances and the sheer geography of mountains and deserts made central rule weak.

But the decades of manipulation, corruption and conflict under Saleh left Yemen underdeveloped and dangerously fragile. Now the civil war, in large part caused by his maneuvering, has pushed it to near societal collapse: With hospitals and food distribution networks in a shambles, hunger is widespread among its population of nearly 28 million and it faces a ferociously fast-spreading cholera outbreak.

"We're on the brink of famine," David Beasley, who runs the U.N. World Food Programme, the largest humanitarian aid agency, told CBS' "60 Minutes" in an interview broadcast in November. "If we don't receive the monies that we need in the next few months, I would say 125,000 little girls and boys will die."

The U.S. is the agency's biggest donor, so the director is most often an American. Beasley was once governor of South Carolina.

"We've been able to avert famine, but we know three things are happenin'," Beasley told "60 Minutes" correspojndent Scott Pelley. "We know that people are dying. We know that people are wasting. And we know that children are stunting. We have a stunting rate in Yemen now at almost 50 percent. That means they're smaller, the brains are smaller, the body's smaller because they're not getting the food nor the nutrition they need."

In the 2000s, Saleh was a vital ally of the United States in fighting al Qaeda's branch in his country, a top priority for Washington after the branch tried to blow up a passenger jet and carry out other attacks on American soil. Even while taking millions in U.S. aid, Saleh was suspected of striking deals with the militants and enlisting them to fight his battles.

Officials from his ally, Saudi Arabia, fumed privately to American diplomats that he was "corrupt, unreliable and largely ineffective," then rushed to help him fight civil wars and domestic conflicts because they needed him. During one of those wars, a leaked U.S. diplomatic memo suggested that Saleh tried to trick Saudi Arabia into killing his own military commander-slash-ally-slash-rival, Ali Mohsen al-Ahmar, by calling in a "mistaken" Saudi airstrike on his home. Saudi Arabia realized what the target was and called off the strike.

After a popular uprising against his rule erupted in 2011, Saleh cannily managed to hang onto power for months, even surviving a bomb that detonated in the presidential palace mosque as he prayed there, severely burning him. Still, he stayed on, only finally resigning in early 2012 under a Saudi-brokered deal.

As president, Saleh fought multiple wars against the Houthi rebels in their heartland in northern Yemen, each time failing to crush them completely. Then after his fall, he allied with the Houthis against his own former vice president and successor, Abed Rabbo Mansour Hadi - likely in hopes he could ride them back into power.

Saleh's loyalist military units helped the Houthis overrun the capital, Sanaa, and much of the north and center of the country. Hadi fled, his government moved to the southern city of Aden and Saudi Arabia and its allies launched a coalition air campaign in early 2015. Then in recent months, Saleh's alliance with the Houthis fell apart as the rebels moved to weaken him and Saleh flirted with switching to side with the Saudi-led coalition.

Saleh rose to power in an era when Yemen was divided into two nations, north and south. He was born into a small tribe allied with one of the country's mightiest clans, al-Ahmar. He did not stay long in school, leaving before he was a teenager and enlisting in the armed forces.

His age wasn't known for sure. His website gives his birth date as March 21, 1946, but many in Yemen say he was born four years earlier. On the other hand, he just happened to be 40 when he took power in 1978 - when the constitution said the president had to be 40. And in the 2006 election, official statements alternated between saying he was 64 or 65.

Whatever his age, Saleh was ambitious and soon caught the eye of North Yemen's president, Ahmed bin Hussein al-Ghashmi, who appointed him military chief in the city of Taiz, south of Sanaa.

Saleh's moment came after a bomb in a briefcase killed al-Ghashmi in June 1978. Within a month, Saleh was North Yemen's president, backed by Saudi Arabia. Among his first acts was to order the execution of 30 officers - some his former friends - convicted of being conspirators in al-Ghashmi's assassination.

His reputation cemented as a tough leader, he also knew how to play Cold War politics. Marxist South Yemen was a Soviet client state, so Saleh reached out to Western leaders to leverage aid for North Yemen.

In 1990, with the Soviet Union unraveling, Saleh negotiated unity with the south, ensuring his place as the president. On May 22, 1990, he raised the flag of the Republic of Yemen at the southern port of Aden. Four years later, he crushed an attempt by the south to break free.

His powerful nexus of the military and tribes made him virtually untouchable. He also sought to harness a dangerous new force in the country. Arab militants who had fought the Soviets in Afghanistan in the 1980s needed a new home, and the deal apparently offered by Saleh was sanctuary in exchange for respecting his authority.

In 2000, that legacy came back to haunt him when the Navy destroyer USS Cole was bombed in Aden harbor, killing 17 American sailors. Washington demanded Saleh to crack down on suspected Islamic militants.

Saleh's efforts against extremist groups were widely criticized as spotty and ineffective. In 2006, a band of al Qaeda militants made a bold escape from a Sanaa prison that U.S. and Yemeni officials believed had help from regime insiders. The band went on to form al Qaeda in the Arabian Peninsula, the terror network's Yemen branch. The group was linked to the attempt to bomb a Detroit-bound airliner on Christmas Day 2009 and a shipment of explosive-rigged packages intercepted in Britain and Dubai in 2010. Still, the U.S. saw little choice but to partner with him.

Saleh's tribal and political allies were growing impatient, complaining that he was ignoring widespread poverty and that corruption was undermining development. Most disturbing to them, he was centralizing power in his and his family's hands. He put his sons and nephews in command of his strongest security units. He appeared to be grooming his son Ahmed, commander of the elite Republic Guard, to succeed him.

When a popular uprising broke out against him in 2011, he responded with token promises of reform, then bloody attacks on the protesters. He faced a stream of defections from his party, lawmakers, Cabinet members, tribal allies and military units. Still, he managed to cling to power, then negotiate an exit deal that not only protected him from arrest and prosecution and let him stay in the country but kept many of his loyalists in place in the military.

That made Saleh a player in the civil war between the Houthis and Hadi. But the Houthis succeeded in weakening him in recent months, reducing their alliance on him. In the hours after his death, many of the Saleh loyalist units were reportedly pulling back from their positions in Sanaa.