The Taliban faced the first armed challenge to their rule as former Afghan soldiers, aided by villagers, drove the militants out of three districts in the mountains north of Kabul, according to former Afghan officials.

The fighting took place in remote valleys Friday, and details of the clashes were still trickling out. But video posted on social media showed fighters and civilians tearing down the white flag of the Taliban and raising the red, green and black Afghan national flag. In a tweet, the former acting defense minister, Bismillah Khan Mohammadi, called the fighters “popular resistance forces,”

“The resistance” he wrote, “is still alive.”

How long it could survive is another question. Afghan troops were said to have retreated to the area last week as the country’s government and military collapsed around them, and the United States appeared to have little appetite for anything that could anger the Taliban, on whose goodwill the evacuation operations at Kabul’s airport is now largely dependent.

Advertise with us

The fighting was reportedly set off by the Taliban conducting house-to-house searches, an ironic twist in a war during which Afghan anger at American searches helped swell the ranks of the militants. Former Afghan officials said the clashes appeared to have been led by a local police chief who knew he was not long for his post under Taliban rule.

The fighting took place in three districts — Pul-e-Hesar, Deh-e-Salah and Bano — that are about 100 miles north of Kabul but only reachable by poor roads that wind through the mountains. The fighters claimed to have killed as many as 30 Taliban and captured nearly two dozen more. A pro-Taliban Twitter account put the militants’ death toll at half that number.

Less than a week after the Taliban swept into Kabul, the militants are already facing the first stirrings of resistance to their renewed rule. Small groups of women, fearful that the Taliban will try to reimpose their stringent and often brutal interpretation of Islamic law, have braved retribution to publicly demand their rights.

Friday's uprising took place north of the Panjshir Valley, a strategic sliver of territory where a handful of Afghan leaders were organizing a force to resist the Taliban. While former Afghan officials and reports from witnesses on social media suggested the uprising was local and spontaneous, one of the leaders of the Panjshir resistance movement claimed Saturday that “we are one.”