BEIRUT — Eight months after launching a war in Yemen, Saudi Arabia appears trapped in a protracted and devastating conflict that is straining relations with its allies, intensifying internal power struggles and emboldening its regional rival, Iran, analysts say.

Since March, the key U.S. ally has led a coalition of mostly Gulf Arab countries and Yemeni fighters in a military campaign to drive out Iranian-aligned rebels who seized the capital, Sanaa, and swaths of the Arabian Peninsula country.

But the coalition appears increasingly hobbled by divisions and unable to find a face-saving way to end the costly conflict.

The rebels, known as Houthis, still control much of Yemen’s north. And in southern areas where the coalition has driven them out, lawlessness has spread as attacks linked to an Islamic State affiliate wreak havoc.

Saudi Arabia is the region’s Sunni Muslim powerhouse and fears that Shiite Iran is using the Houthis, who are also Shiite, as proxies in Yemen.

The rebels toppled the Yemeni government in February, forcing President Abed Rabbo Mansour Hadi to flee to Saudi Arabia. The Saudi-led coalition — which includes Bahrain and the United Arab Emirates — responded with airstrikes and then a ground ­offensive in an effort to return Hadi’s government to power.

Speaking by telephone, Brig. Gen. Ahmed Asseri, a spokesman for the Saudi-led coalition, said it “is too early to make judgments” about the campaign.

But as the conflict drags on, mounting civilian casualties and a worsening humanitarian crisis have drawn criticism from international rights groups and lawmakers in the United States, an arms supplier for the key oil producer. More than 5,400 people have been killed since the intervention began, and U.N. officials warn of famine in the desperately poor country of 25 million people.

The United States has provided logistical and intelligence assistance to the Saudis in their campaign in Yemen. U.S. intelligence officials have expressed concern that the conflict has strengthened Yemen’s al-Qaeda affiliate.

The United States has also expressed concern about the civilian toll but has refrained from directly criticizing Saudi Arabia for its attacks, including one on the Yemeni port city of Mokha that killed 65 people in July.

“The United States has no role in targeting decisions made by the coalition in Yemen,” the National Security Council said in a statement last month.

Royal power struggles

Inside Saudi Arabia, analysts say, the war has intensified apparent power struggles within the secretive and opaque royal family.

King Salman, who took power in January, has rattled the kingdom with shake-ups, including the appointment of his 30-year-old son to become deputy crown prince and defense minister, placing him in charge of the Yemen campaign. An economy battered by low oil prices has added to the friction. Dissenters within the royal family have released several open letters criticizing the king.

“It’s all somewhat murky, of course, but the war is generating this competition for power,” said Yezid Sayigh, a Middle East analyst at the Carnegie Middle East Center.

The relatively small number of Saudi troops fighting in Yemen — estimated at several hundred — signals Saudi rulers’ heightened concern about the potential domestic blowback over casualties from the war, Sayigh said.

Despite requests from Saudi Arabia, allies such as Egypt and Pakistan appear to have refused to send in ground forces. Several thousand UAE troops have taken the lead on the ground in Yemen.

But allied Yemeni fighters say the coalition has deployed far too few soldiers, causing a land offensive that began in June to falter.

“We haven’t received enough support from the coalition,” said Aref Jamel, a senior commander of a militia group that is fighting Houthi rebels in Taiz, Yemen’s third-largest city.

The battle for Taiz has been especially brutal, with rebels indiscriminately shelling civilian areas and cutting off supplies of water and food to the city. Anti-Houthi militias in the city, which is about 160 miles south of the capital, say they have been left on their own in the fight.

In Marib province, also within striking distance of Sanaa, coalition forces appear to be mired in back-and-forth battles. In September, a Houthi-fired missile killed at least 60 Saudi, UAE and Bahraini troops in the province. But it is unclear whether a deployment of reinforcement troops from Qatar — reported by Qatari media after the missile incident — actually arrived, said Ahmed al-Zayedi, a pro-coalition tribesman in Marib.

“There isn’t enough support from the coalition, and there is a lot of frustration” among anti-Houthi tribes in the area, he said.

Chaos in Aden

Perhaps more alarming for Saudi Arabia is the lawlessness plaguing Aden, the key southern port city that coalition ground forces seized from the rebels over the summer.

In October, an Islamic State affiliate asserted responsibility for bombings that targeted coalition troops as well as an Aden hotel used as a headquarters for the Hadi government. Government ministers fled the city after the attacks.

Meanwhile, conservative Islamists — including some who openly fly al-Qaeda’s flag — have stormed universities and markets in Aden to demand the separation of men and women in public spaces, residents say.

Saudi and UAE troops in the city, he said, keep out of the public eye. “We don’t understand what their role is here,” Hariri said.

It is unclear how Saudi Arabia can end its military involvement without coming off as the loser. A ground assault to wrest Sanaa and northern areas from rebel control could produce many coalition casualties. Further, U.N.-backed peace efforts have repeatedly failed, while rebels are escalating the fight by launching cross-border attacks into southern Saudi Arabia.

Christopher Davidson, an expert on Persian Gulf countries at Durham University in Britain, said Iranian leaders view the Saudi troubles in Yemen as a strategic gain in the countries’ competition for influence in Syria’s civil war and elsewhere in the region. Iran backs the government of Syrian President Bashar al-Assad, while Saudi Arabia supports the opposition.

Hugh Naylor is a Beirut-based correspondent for The Post. He has reported from over a dozen countries in the Middle East for such publications as The National, an Abu Dhabi-based newspaper, and The New York Times.