HERAT, Afghanistan — Taliban fighters killed or captured an entire Afghan National Army company of more than 50 soldiers on Monday, Afghan officials said, the latest in a series of major attacks by the militant group even as it pursues a peace deal with the United States.

The attack, in which the Taliban were reported to have killed 16 soldiers and taken 40 prisoner, took place in northwestern Badghis Province, close to the country’s western border with Turkmenistan. It came as Taliban negotiators entered a third week of talks with American diplomats in the Persian Gulf kingdom of Qatar.

In the assault, a large force of Taliban insurgents surrounded a base in the Bala Murghab district. After four hours of fighting, the militants captured or killed all of the soldiers in their base, as well as others at two outposts nearby, according to Abdul Aziz Beg, head of the Badghis provincial council.

The episode was the deadliest in a weeklong insurgent campaign that has killed, wounded or captured 70 soldiers in the district, Mr. Beg said. “The district is on the verge of collapse,” Mr. Beg said. “The fighting has gone on for a week, but the government is not paying any attention.”