KABUL — A Taliban offensive in southern Helmand province has raised concerns here that a growing wave of insurgent violence could undercut fledgling intra-Afghan peace talks in Qatar and sabotage a U.S.-Taliban pact reached in February.

The multiday assault in several areas near Lashkar Gah, the provincial capital, was partly quelled by Afghan forces Tuesday with support from U.S. airstrikes, but thousands of families were forced to flee the surrounding areas, highways were blocked, and some Taliban fighters were reported Wednesday to still be advancing into the city.

The complex attack appeared to have been planned before President Trump tweeted last Wednesday that he wanted to bring all U.S. troops home by Christmas, a significant shift in policy that immediately put the Taliban in a stronger bargaining position at the peace talks, which have been bogged down in disputes for a month.

But it also appeared to violate the intent, if not the letter, of the U.S.-Taliban deal, which included Taliban pledges to avoid attacking Afghan cities, reduce violence in general and cut ties with terrorist groups. In return, the United States agreed to gradually withdraw all troops by May, as long as the insurgents met those conditions.

In the months since the pact was signed, the insurgents have unleashed a nationwide campaign of violence, killing thousands of civilians and troops, but have stopped short of full-fledged assaults on cities.

This week, their spokesman insisted that the Helmand offensive was not aimed at Lashkar Gah, which the group has tried to capture numerous times, but at security posts in the surrounding area.

A spokesman for the Interior Ministry, however, said the Taliban had “failed to fulfill their promises” under the U.S. deal with its surge of attacks in Helmand and elsewhere. The violence has sent thousands of people fleeing into Lashkar Gah for protection and medical help.

Doctors Without Borders, an international charity, reported that the city’s trauma hospital was “overwhelmed” and that a stray bullet had hit a pregnant woman, killing the fetus, although the mother survived.

As dramatic images from Helmand dominated the national news, alarm mounted. The top U.S. Embassy official and the senior U.S. military commander here appealed to the insurgents Tuesday to halt the violence. Gen. Austin Scott Miller said the assault was “not consistent with the U.S.-Taliban agreement and undermines the ongoing Afghan peace talks.”

The Oct. 7 tweet from Trump, which spurred fears among Afghans that the peace talks could collapse if U.S. forces pulled out prematurely, seemed likely, however, to further embolden the Taliban and weaken the effect of such appeals. To many, the assault on Helmand seemed a direct challenge to the U.S. commitment here.

“The Taliban control 14 districts in Helmand. They can capture areas anytime they want. They only did this to show their force to the Americans,” Hadia Helmandi, a women’s rights leader, said on ToloNews TV. “This was a massive attack that displaced thousands of poor people. They planted bombs along the highways. The generals are saying the Afghan defense forces are ready to defend us against enemy attacks, but why was nobody paying attention?”

The government belatedly sent in special operations forces, backed by Afghan warplanes, and, ultimately, limited U.S. airstrikes were launched to defend the government forces. Afghan officials said that at least 80 Taliban fighters had been killed, but on Wednesday, some were reported to still be trying to reach Lashkar Gah. On Tuesday night, two Afghan army helicopters in Helmand crashed, killing nine, officials said.

Najiba Faiz, a civil activist reached in Helmand on Wednesday, described the situation as “critical.” She said that all the security outposts in three districts had been destroyed and that their forces had either been killed, taken captive, retreated or surrendered to the Taliban.

“All the people in Lashkar Gah are up all night, staying in basements,” she said. “They are scared the city will fall at any hour.” Reports of civilian casualties in Helmand have varied widely and have not been confirmed.

Meanwhile, a man arrested Monday on suspicion of being a key player in the insurgents’ offensive was identified as a former Taliban “shadow” governor who had been recently released from prison as part of a massive prisoner swap. The government resisted at first but finally freed about 5,000 Taliban prisoners under strong U.S. pressure.

The crisis spurred conflicting opinions among Afghans about the role of U.S. forces here. Some said that they are needed more than ever and that Trump’s plan to pull them out early would encourage the Taliban to push harder. Others said that a swift U.S. withdrawal would help reduce the violence and allow the peace talks to proceed. About 4,500 U.S. troops remain in the country.

“The American airstrikes are absolutely being demanded by the people. It is the only way to push back the Taliban,” Ghulam Wali Afghan, a legislator from Helmand, said Wednesday. But he said he feared that even U.S. help would not stop the insurgents from overrunning parts of Lashkar Gah. “The clashes are intense, and there is total destruction.”