In this Sept. 21, 2019, file photo, Shiite Houthi tribesmen hold their weapons during a tribal gathering showing support for the Houthi movement in Sanaa, Yemen. Credit: Hani Mohammed | AP

Some wars end in victory, but just as many sputter out in exhaustion. The war in Yemen, now coming up on its fifth year, always looked likely to end up in the second category, and the time may be quite soon.

It would be not a moment too soon, as the war has already killed at least 100,000 Yemenis, and four-fifths of the country’s 30 million people need humanitarian aid. But last month the Saudi-led coalition, whose bombs have devastated the country, said it would free 200 Houthi rebel prisoners and let injured civilians fly out of Sana’a, the rebel-held capital, for medical care abroad.

The Saudis are making these overtures because they are actually managing, very slowly, to lose the war. They have a monopoly of air power, so they can bomb anything that moves — including an improbable number of wedding parties. Their coalition of Arab dictatorships and monarchies, from Egypt to the United Arab Emirates, gives them ample troops on the ground. And still they cannot win.

Saudi Arabia generally avoids committing its own troops to ground combat, but the Houthis are now taking the war to Saudi territory. Their claim to have killed 500 Saudi troops and captured a further 2,000 in a raid into southwestern Saudia Arabia may be exaggerated, but something big of that sort clearly did happen in late September.

That followed an extraordinarily successful attack by cruise missiles and armed drones on Saudi Arabia’s two largest oil-processing facilities in mid-September. Riyadh tried to blame Iran, as usual, because it’s just too humiliating to be bested by poor, ragtag Yemenis, but it probably was the Houthis who did it.

And the Saudi-led “coalition,” such as it was, is falling apart. The United Arab Emirates, which was responsible for operations in the south of Yemen, has now transferred its loyalty from the Saudi-backed, “internationally recognized” government of Abdrabbuh Mansur Hadi to the Southern Transition Council, a separatist group that wants to recreate the old independent state of South Yemen.

So this squalid, stupid war may finally be heading for a long-term cease-fire. There probably won’t be an actual peace settlement, because Crown Prince Mohammed bin Salman, Saudi Arabia’s de facto ruler, will want to disguise his defeat (for it was his “war of choice”). But it would still be a great boon for the Yemeni people.

The horrors of the past five years came to pass because the Saudis exploited the overthrow of long-ruling Yemeni dictator Ali Abdullah Saleh in 2012 to maneuver their own man, Abdrabbuh Mansur Hadi, into power as the transitional president. Why?

Their man Hadi started out in 2012 with a two-year mandate, to be followed — in theory — by a democratic election. Instead, he stayed in power after his mandate expired and promoted a new constitution that would “decentralize” the country and cut the more heavily populated northern part of Yemen out of any share of the oil revenues.

Hadi’s game was simply to redirect the flow of oil revenues to himself and his cronies, but it also served Saudi Arabia’s purposes because it would deprive northern Yemen of this income. Most northern Yemenis, and particularly the Houthi tribes, are Shiites, and Sunni Saudi Arabia always suspects them of being in cahoots with its great rival across the Gulf, Shiite-ruled Iran.

There is no evidence that the Iranians ever sent the Houthis anything more than their best wishes, but the Houthis saw what Hadi was trying to do to them and rebelled against him. He fled to Saudi Arabia and has been there ever since, while his “internationally recognized” government (it was never elected) fought a Saudi-controlled war to put him back into power.

It has now become clear that Saudi Arabia is never going to win. After five years of war the Houthis still control three-quarters of the population, they probably have majority popular support, and the anti-Houthi coalition is breaking up. The winners are clear, and it’s time to stop the war.

The tricky bit will be finding a way for His Royal Highness Crown Prince Mohammed bin Salman to walk away without being openly humiliated. That may take some time — and some more deaths, of course.

Gwynne Dyer’s new book is “Growing Pains: The Future of Democracy (and Work).”