SANA, Yemen — After five months of war in which more than 4,000 people have been killed, Yemen’s government, exiled in Saudi Arabia, faces a fateful decision: leverage recent battlefield gains to negotiate a cease-fire with a weakened Houthi rebel movement, or try to rout the rebels once and for all.

Backed by air support and ground troops from Persian Gulf nations, fighters allied with the government have made significant progress in recent weeks, after Saudi Arabia and the United Arab Emirates poured men and matériel into the strategic southern port city of Aden. The Houthis were driven from the city in July and since then have suffered a string of defeats in southern and central Yemen.

Yemen’s ambassador to the United Nations struck a bullish note last week, predicting that the government and allied forces would be ready to take back Sana, the capital, within weeks.

“It seems they are on the run,” the ambassador, Khaled Alyemany, said of the Houthi militias after a meeting with members of the United Nations Security Council on Wednesday. “My feeling is it’s going to be weeks before we can liberate the entire country from the coup,” he said, referring to the government’s forced resignation at the hands of the rebels in February.

Diplomats and analysts of the region warn against such optimism. They point out that any military effort to rout battle-hardened Houthi fighters from their strongholds in the north would risk a protracted blood bath, aggravate the regional rivalry between Sunni states and Shiite-dominated Iran, and compound one of the world’s worst humanitarian crises.

Intense diplomatic efforts have been underway to persuade the Houthis to withdraw their fighters from cities and to encourage the government and its Saudi backers to halt the airstrikes, according to people with knowledge of the talks.

The Houthis are said to have agreed to concessions, but the insistence by factions in the government that the war should continue has alarmed diplomats who fear that the entrance of Persian Gulf troops into the conflict could prompt Iran to intervene militarily on behalf of the Houthis, their allies.

The United Nations mediator, Ismail Ould Cheikh Ahmed, traveled to Riyadh, the Saudi capital, this week after meetings with Houthi leaders in Oman.

The escalation of the war would also benefit Al Qaeda’s powerful Yemeni affiliate, which has seized territory during the conflict and has remained largely unchallenged, controlling the Yemeni city of Al Mukalla.

Abdel-Karim al-Iryani, a former Yemeni prime minister who has been involved in mediation between the warring sides, said that if the Houthis had agreed to concessions in line with a Security Council resolution on Yemen, “we’re on the road to peace.”

But the Saudi-backed government’s talk of vanquishing the Houthis “is destructive,” he added.

“There is no to need to win the war, in the sense of humiliating and defeating the other side,” Mr. Iryani said.

While it is true that the anti-Houthi forces have improved on the battlefield, he added, “they are not in a prevailing position.”

Yemen fell into its latest crisis in September, when the Houthis, a Shiite-led rebel movement from northern Yemen, stormed the capital. The rebels, whom the Saudis regard as an Iranian-backed proxy force, drove the government of President Abdu Rabbu Mansour Hadi into exile.

A Saudi-led military coalition began bombing the Houthis in late March. The air campaign and ground fighting between the rebels and rival militias have killed thousands of civilians and made living conditions dire throughout Yemen, the poorest Arab state.

Reeling from power cuts, Sana is cloaked in darkness at night. Fighting across the country has left more than 4,300 Yemenis dead. Of the survivors, one in five faces starvation.

A United Nations expert this week warned both sides in the conflict about “the deliberate starvation of civilians,” which constitutes a war crime. The United Nations estimates that 850,000 children in the country of 26 million now face acute malnutrition.

The Obama administration has supplied weapons to Saudi Arabia and provided the Arab coalition fighting the Houthis with intelligence and logistical support. But American as well as British diplomats have been encouraging the combatants to make political concessions, believing neither side is likely to prevail in the war, according to analysts.

Southern anti-Houthi fighters recaptured Aden last month with the help of Saudi and Emirati special forces and Yemeni fighters trained in the Persian Gulf. As those fighters have consolidated their control around Aden, the Houthis are facing new challenges from local fighters in the province of Ibb, between Sana and Aden, as well as in Arhab, about 20 miles north of Sana.

Yemenis trained in Saudi Arabia are believed to have joined the fighting in Marib Province, east of the capital, further squeezing the Houthis.

“It has become more and more clear that the focus is Sana,” said April Longley Alley, a Yemen researcher at the International Crisis Group, speaking of the Saudi-backed forces. “Actions on the ground indicate they smell blood and are on the warpath.”

After a long period in which the Houthis were faulted for overreaching and intransigence, “the tables have turned,” she said.

“The government is at risk of overconfidence, and increasing the suffering,” Ms. Alley said.

Mohammed al-Bukhaiti, a senior rebel leader, said that the Houthis “were not against withdrawal” from Yemeni cities, as long as their Saudi-backed opponents stopped making “unilateral” decisions and engaged in “serious dialogue” about the shape of the postwar political order in Yemen.

But as their enemies close in, the Houthis have been accused of resorting to the kind of repression that has alienated many Yemenis over the last year, including arresting political opponents in the capital and other cities.

“There has been an unprecedented deterioration of human rights,” said Abdilrasheed al-Faqih, the director of the Muwatana Organization for Human Rights in Sana, who said he was beaten recently by Houthi fighters when he tried to assist political detainees.

The Houthis have also talked ominously about unspecified “strategic options” that they might use to repel their enemies if dialogue fails.

“We hope we won’t resort to taking them,” said Mohammed Ali al-Houthi, a senior Houthi leader. “They will be so painful and will change the equation, God willing.”