Former Yemeni President Ali Abdullah Saleh never gave up trying to stay in power, even when his country and international allies ultimately forced him from the presidency five years ago.

Saleh, reported to have been killed Monday, never wavered in his belief that only he could lead the Yemenis, even though he fueled societal divisions by playing enemies off one another to weaken his opposition.

He did "a very good job of what he like[d] to call 'dancing on the head of snakes,'" said Gregory Johnsen, an author and former Fulbright Fellow in Yemen.

It was an approach Saleh, a former tank driver with an elementary school education, crafted and honed over nearly four decades as a strongman in Yemen.

Saleh — whose website says he was 71 but who is widely reported to have been 75 when he was killed — came to power in 1978, after two predecessors were assassinated. At the time, Yemen was divided into two nations, and Saleh focused on reconnecting his home region of northern Yemen with the Marxist south.

He became president of a unified Yemen in 1990 and four years later, managed to put down a new secessionist movement in the south.

He proved less skilled at international diplomacy, when he aligned himself with Iraqi leader Saddam Hussein in the fall of 1990, said Ginny Hill, an author and fellow at the London School of Economics Middle East Center.

"The Gulf states, Saudi Arabia, were furious with Yemen, but so was America," Hill said. "This was a period when [Yemen] was just trying to consolidate the military and bureaucratic structures of two very, very different states. As a result, aid spending was drastically reduced and a million Yemenis were sent home from the Gulf states who'd been providing valuable remittances."

The terrorist attacks of Sept. 11, 2001, offered Saleh a chance at redemption. He revamped his image as leader of a country harboring al-Qaida to an aggressive partner in the war on terror — and collected millions of dollars in U.S. aid to hunt down the group's Yemeni branch.

But Saleh faced growing discontent at home.

The president oversaw a patronage system in which oil and other resources went to enriching his allies, said Ellen Knickmeyer, a journalist and former fellow at Harvard's John F. Kennedy School who has covered Yemen for news organizations including the Wall Street Journal and Washington Post.

"He's never taken care of the little people, so that while the elites have been getting patronage payments, ordinary people have been seeing their standard of living actually decline over his time in office," Knickmeyer said.

Corruption was also rampant. By early 2011, many Yemenis decided they'd had enough. Emboldened by the popular uprisings in Tunisia and Egypt, they took to the streets. Saleh tried but failed to keep the unrest at bay with a mix of promises, cajoling and violent crackdowns.

"Saleh racked up a very significant trust deficit," Johnsen said. The turning point was the shooting of some 50 people by snipers at an opposition rally in Sanaa in March 2011.

Saleh sought to distance himself from that attack, but it was too late. His international allies — including the U.S. and Yemen's Arab neighbors — pressured the ruler to step down. He did so in February 2012. The Gulf states drafted a proposal that granted Saleh and his family immunity from prosecution and safe passage from Yemen.

But Saleh refused to give in, even after he was badly wounded in a June 2011 attack on his presidential compound in Sanaa.

He was rushed to Saudi Arabia for emergency treatment. Three weeks after the attack, he looked old and frail when he appeared on TV, but he vowed he would return to Yemen to "face the challenges."

Saleh "always made a strong point of saying that if he is not in power, there's going to be chaos in Yemen," Knickmeyer said. But "he created a great deal of that chaos himself. He allowed it to happen with al-Qaida and all kinds of other problems."

In 2012, under mounting pressure domestically and abroad, Saleh turned the presidency over to his deputy, Abed Rabbo Mansour Hadi.

Saleh later joined with the Iranian-backed Houthi militias. His loyalist military units turned against Hadi, who is backed by a Saudi-led coalition, and sparked a civil war in 2015 that drove the new president's government out of Sanaa. The war continues to this day.

The Saleh-Houthi alliance frayed, and Saleh parted ways with the rebels. On Saturday, he said he had turned a "new page" and was open to a rapprochement with Hadi and the Saudi-led coalition.

After violence engulfed Sanaa over the weekend, Houthi officials say their fighters caught up with the former president as he fled with top party leaders, trying to reach his nearby hometown of Sanhan. A grisly video circulating online is believed to show rebel fighters carrying Saleh's body with a gaping head wound.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.