Yemen's future looks grim after Saleh's killing
Having avoided the fate of fellow Arab autocrats in 2011, Yemen's former President Ali Abdullah Saleh has been killed in a roadside gunfight while attempting to flee the capital Sanaa.
Saleh will be remembered as the man who shaped modern Yemen in his own image, but who was more willing to burn the country to the ground than relinquish power.
Yet without his deal-making skills, the civil war he helped to spark and the devastating humanitarian crisis it caused are only likely to get worse.
Saleh's death came as a shock to most Yemenis. He loomed large over the country, living on his wits - he likened ruling Yemen to "dancing on the head of snakes" - and was a consummate deal-maker who exceeded and outlived all expectations.
Shortly after Saleh was named president of North Yemen in July 1978, the local CIA station chief predicted that he would be dead within six months - the latest in a series of Yemeni leaders to fall victim to infighting.
He went on to rule for 33 years, surviving any number of assassination attempts - including a near-fatal bombing in 2011 - and even coming close to clawing his way back into power after being ousted during an Arab Spring uprising that year.
As president, Saleh oversaw the merger of North and South Yemen, fought two civil wars, and formed and abandoned any number of alliances of convenience in the process: with tribesmen, Islamists, technocrats, jihadists and latterly the Houthis, a group of Zaidi Shia rebels who he had spent almost a decade trying to crush.
It was during a typically audacious manoeuvre - turning on the Houthis and offering to link up with Saudi Arabia, who he had been fighting alongside the Houthis - that Saleh met his demise.
Ironically, he was close to accomplishing what he set out to do after being ousted - a deal was on the table that would allow him or his son, Ahmed Ali, to return to power - but he finally overplayed his hand after a lifetime of risky gambles.
On Friday, Saleh announced a split from the Houthis, who he helped seize Sanaa in September 2014.
He offered to "open a new page" with Saudi Arabia, which entered the Yemen fray in March 2015 in the hope of decimating the Houthis - who the kingdom sees as an Iranian proxy - and bringing President Abdrabbuh Mansour Hadi back to power.
Saleh helped engineer the Houthis' rise to power in the hope of cutting a deal to bring either himself or his son back into power after 2011 - the least-bad option for regional players like Saudi Arabia and international powers like the US, with which Saleh worked closely in the 2000s on counter-terrorism initiatives.
When the war began, Saleh threw his weight behind the Houthis but continued to signal willingness to deal with the Saudis and the United Arab Emirates, the Saudis' most important partner in the war.
But Saudi Arabia's now-Crown Prince, Mohammed bin Salman, initially resisted Saleh's overtures, hopeful that he could win the war without the slippery former leader's help. (The prince reportedly developed a personal grudge against Saleh after a 2015 meeting with his son, Ahmed Ali, during which the two men almost came to blows.)
With the front lines of the conflict largely static since late 2016 and the Houthi-Saleh alliance fraying - clashes in Sanaa in August left a prominent Saleh ally dead - that calculus would appear to have changed.
A deal seems to have been brokered, contingent on Saleh announcing that he was splitting from the Houthis.
With the Houthis increasingly dominant on the ground that was always going to be a risk, but at first it seemed to be paying off.
Saleh allies took control of southern Sanaa relatively quickly and the Saudis announced their support for what they called a "revolution" against the Houthis.
Pro-Riyadh media switched from describing Saleh as a "deposed dictator" to Yemen's "former president". But the move backfired.
By Sunday, Houthi militias were in control of much of Sanaa and fierce battles were taking place around the homes of key Saleh family members.
Rumours that Saudi-backed Yemeni forces would soon cross front lines near the capital to come to Saleh's aid proved false.
The increasingly embattled Saleh was apparently fleeing the capital when his convoy was stopped at a Houthi checkpoint.
He was either killed in the ensuing gun battle, or - some of his supporters say - executed on the spot.
With Saleh dead and his allied forces apparently crumbling in the face of a Houthi onslaught, the future of Yemen's conflict looks grim.
Having attempted to pull the carpet out from under the Houthis' feet, the Saudis must now decide whether or not to engage in mediation efforts in a climate of zero trust, or to push on with a military campaign that has had few notable successes over the past two and a half years.
Saleh was a divisive figure, but he was also the person most likely to be able to broker some kind of settlement. His death will only lead to deeper polarisation in the conflict.
The Houthi-Saleh alliance was only ever going to be a marriage of convenience.
"Praise be to God!" and "Hussein has been avenged!" Houthi militiamen can be heard saying in a gruesome video showing Saleh's body being carried on to the bed of a pick-up truck in a bright red polyester blanket.
Hussein Badr al-Din al-Houthi, the movement's founder, was killed in a cave in the northern province of Saada in 2004, allegedly on Saleh's orders.
The former president had thought he would come out on the better side of the divorce, but for once his powers of prediction let him down.
Peter Salisbury is a Yemen analyst and Senior Consulting Fellow on the Middle East and North Africa Programme at Chatham House. Follow him @peterjsalisbury.