PRINCE SULTAN AIR BASE, Saudi Arabia — Months of talks between Saudi Arabia and an ­Iranian-allied rebel group in Yemen have led to rare goodwill gestures between the bitter battlefield adversaries and presented what Western diplomats hope might be a long-awaited opportunity to resolve Yemen's nearly five-year war.

But a fresh outbreak of violence in Yemen over the past few weeks has imperiled those talks, underscoring the challenge of defusing long-standing battlefield enmities in a war fueled by outside powers.

The dialogue began in earnest after an attack on Saudi oil facilities in September, according to people briefed on the talks. The rebels, known as the Houthis, claimed responsibility for missile and drone strikes on the oil facilities, even as U.S. and Saudi officials insisted Iran was responsible.

After the strikes, the Houthis said they would halt attacks on Saudi Arabia, and in the months that followed, violence in Yemen fell to some of its lowest levels in years.

Since then, the Houthis and the Saudi-led military coalition have taken several confidence-building measures, including prisoner exchanges and a Saudi decision to allow medical evacuation flights from the Houthi-controlled airport in Yemen’s capital.

Gen. Kenneth “Frank” McKenzie Jr., who heads U.S. Central Command, told reporters during a visit to Saudi Arabia last week that while he detected no “particular new urgency” to strike a deal on the part of the Saudi government, he thought the kingdom’s leaders “feel that the time is right to try to bring this to an end.”

Two weeks ago, Adel al-Jubeir, Saudi Arabia’s minister of state for foreign affairs, noted “a very strong de-escalation” in the fighting in Yemen. “We may have some skirmishes from time to time, but the trend is toward a political settlement,” Jubeir said at the World Economic Forum in Davos, Switzerland.

But Saudi ambitions to wind down the conflict have been dealt a setback since mid-January as parts of Yemen have descended into some of the worst clashes in years, with a resumption of Saudi airstrikes and Houthi missile attacks in fighting that has killed hundreds of people.

“The swing from stalemate and de-escalation to shooting war was sudden,” the International Crisis Group wrote in a recent briefing on the violence, which escalated after a missile struck a military camp in Marib province, killing more than 100 Saudi-backed Yemeni soldiers. No one asserted responsibility for the attack.

“For now, neither the Houthis nor the Saudis wish to abandon the talks, but the de-escalation process is under severe strain,” the group wrote.

Saudi Arabia’s decision to engage in negotiations with the Houthis — a movement it derided for years as both a “terrorist” entity and an Iranian proxy force — had amounted to an acknowledgment by the kingdom that it could not prevail militarily and was being harmed by international criticism, including from the U.S. Congress, over its intervention, analysts said.

Saudi Arabia also sought to tamp down its conflict with Iran in the aftermath of the strikes on the oil facilities, including by reaching out to Tehran through intermediaries.

Houthi leaders had long expressed a desire for negotiations, but progress occurred only after they announced a halt to the attacks on Saudi Arabia. This concession reflected their battlefield strength as well as their possible discomfort at being dragged further into the regional conflict between Iran and the United States, analysts said.

Early last month, the U.S. military carried out a top-secret mission in Yemen targeting a key commander in Iran’s elite Quds Force who was active there but did not kill him.

The Trump administration has also had an interest in promoting dialogue between Saudi Arabia and the rebels. Congressional anger over the administration’s support for the Saudis has been growing, and U.S. officials worry that Yemen was becoming an increasingly dangerous “second front” for Iranian attacks on U.S. regional allies. The U.S. military has argued that the conflict complicates counterterrorism efforts in Yemen and expands Iran’s reach on the Arabian Peninsula.

Martin Griffiths, the U.N. envoy for Yemen, said that a prolonged lull in the fighting starting last fall had represented “a clear demonstration that the parties have shifted their positions toward peace.”

But the flare-up in fighting “is putting everything we gained at a great risk,” he said in a statement.

In the latest fighting, the Houthis have routed government forces and been able to capture strategically important territory.

Mohammed Albukhaiti, a spokesman for the Houthis and member of their political bureau, said that the movement remained “open to dialogue with all parties, including Saudi Arabia” and that Houthi military gains enhanced the possibilities for peace.

“We are with the option of peace at the internal and regional level,” he said.

Yemen’s conflict began in the fall of 2014, when the Houthis captured the capital, Sanaa, and ousted the government. The war deepened after the Saudi-led coalition intervened in March 2015, saying it sought to restore Yemen’s legitimate government and prevent the Houthis from menacing the kingdom from just across its border.

The United States agreed to provide the Saudis with logistical and intelligence support. But Saudi Arabia quickly drew criticism for its air campaign, which killed thousands of civilians in indiscriminate strikes and was blamed for a series of cascading humanitarian crises that gripped Yemen.

The United Nations, meanwhile, has accused the Houthis of shelling urban areas, using child soldiers and holding up humanitarian assistance.

It was only after an event unrelated to the war — the 2018 killing of journalist Jamal Khashoggi by Saudi agents in Istanbul — that the Saudis began to seriously reconsider their involvement in Yemen, according to Abdulghani Al-Iryani, a senior researcher at the Sanaa Center for Strategic Studies, a Beirut-based think tank.

The world turned against them. There was a lot of international pressure to stop the humanitarian crisis in Yemen, and they felt that they had to give in,” he said.

When there was no vigorous U.S. response to the attacks on the oil facilities, “the Saudis quite clearly shifted their strategy,” said Peter Salisbury, senior Yemen analyst at the International Crisis Group. “The sophistication of the attack really left them taking stock.”

Though it was unlikely that the strikes on facilities belonging to Aramco, the Saudi state-owned oil giant, had come from Yemen, “there was [a] sense that if there was an opportunity to take Yemen off the table and reduce Iran-backed attacks across the southern border, they should take it,” Salisbury said.

To the Saudis, he added, the Houthis “gave the impression of being more serious about de-escalation than in the past.”

Days after the Aramco strikes, Mahdi al-Mashat, a top Houthi official, announced that the movement was halting attacks on Saudi Arabia with “military drones, ballistic missiles and all other forms of weapons.”

Elana DeLozier, a scholar at the Washington Institute for Near East Policy who has closely studied the Houthi movement, said the rebels may have made the offer because they felt they had the “upper hand,” at a moment when the Saudis were reeling from the Aramco strikes as well as Houthi cross-border attacks that the rebels claimed had resulted in the capture of hundreds of Saudi-backed fighters.

Iryani, of the Sanaa Center, said that both the Saudis and the Houthis had an interest in returning to the negotiating table, if only to ensure that Yemen remained a unified state. For the Saudis, “there is no reason for them to disrupt the situation in Yemen and create more instability they cannot control.” And the Houthis were looking to maintain the power they had accumulated during the war.

While McKenzie said the recent fighting did not aid prospects for peace, he identified Iran’s support for the rebels as the bigger problem.

“It is in the Houthis’ best interest probably to come to some political deal. It is not necessarily in Iran’s best interest for that outcome to occur,” he said.

Fahim reported from Istanbul. Ali Al-Mujahed in Sanaa contributed to this report.

Read more