The Taliban in this northern province allows girls to attend school. It doesn’t execute soldiers or police. Its fighters are not Pashtun, the main ethnic group that bred and fueled the insurgency. Some members are even former mujahideen, or freedom fighters, who once despised the Taliban and fought against its uprising.

“The Taliban here are against the ideology of the Taliban in the south,” explained Maizuddin Ahmedi, 20, a former Taliban member who reflects the local faction’s atypical nature: He has a Facebook page, tweets regularly and wears a beanie emblazoned with “NY.”

“They don’t behead soldiers,” he said.

As the United States reshapes its military footprint in Afghanistan, the Taliban is transforming into a patchwork of forces with often conflicting ideals and motivations, looking less like the ultra-religious movement it started out as in the mid-1990s. The fragmentation may suggest the movement is weakening, but it is forcing Afghanistan’s government to confront an insurgency that is becoming increasingly diverse, scattered — and more lethal.

What is unfolding here in Badakhshan province offers a glimpse into these complexities — and the future of a conflict in which the U.S. combat mission is formally over. When the Taliban ruled Afghanistan, from 1996 to 2001, this was the only province it was never able to control. Now, the insurgency is making inroads here and in other parts of the north, outside its strongholds in the south and east.

The Taliban in Badakhshan has gained strength precisely because it is different from the core insurgency. Its fighters are using their ethnic and tribal ties to gain recruits and popular support, while their knowledge of the landscape helps them outmaneuver Afghan security forces and control lucrative sources of funding.

“They are trying to make northern Afghanistan insecure,” Shah Waliullah Adeeb, the provincial governor, said in an interview in December. “By seizing areas in Badakhshan, they are trying to send a message that the national government is weak and inefficient, and helpless.”

America’s longest war has officially ended, at least in the form that manifested itself for the past 13 years, with tens of thousands of foreign troops, high-tech weaponry and countless airstrikes. The roughly 13,000 U.S. and NATO soldiers who remain have shrunken capabilities and more restrictions, and their ranks are scheduled to grow even smaller by the end of the year.

But Afghanistan remains an unfinished conflict. In Iraq, the U.S. withdrawal coincided with a reduction in violence. Here, the bloodshed is rising. Last year, there were more civilian and
security-force deaths than in any year since the U.S.-led intervention ousted the Taliban government in 2001.

In Badakhshan, a struggle is underway to prevent the Taliban from gaining more territory in this strategic corner that borders three nations — Pakistan, China and Tajikistan — and is a gateway for the smuggling of opium to Europe. In the provincial capital, Faizabad, ringed by snow-covered mountains, there lingers a sense of disbelief that the region is now as fragile as any other in Afghanistan. “We never expected the Taliban to rise up here,” said Gen. Nazir Mohammed Nayazee, the mayor of Faizabad.

‘Not ideological Taliban’

Nayazee, a former top mujahideen commander, speaks with the authority of experience. He was shot twice fighting the Soviets in the 1980s and wounded twice battling the Taliban in the 1990s.

In 1997, a year after it seized Kabul, the Taliban pushed northward. But it was stopped at Badakhshan’s borders by Nayazee and his mujahideen forces. Under fire from cragged mountaintops, the Taliban could not break through the narrow passes.

But in recent years, Afghan security forces have focused on fighting the militants in the south and east, leaving northern areas largely unprotected. In Badakhshan, security forces are ill-equipped and overstretched. When NATO troops departed the province in 2013, the Taliban seized more ground.

Today, the insurgents have injected themselves into seven districts, a quarter of the province. They number around 800 to 1,000 fighters, according to provincial officials, and their command center is a mere 40 miles east of Faizabad. They have set up a shadow government, and fighters man checkpoints in villages.

“The security forces can’t do anything against them,” said Sadiqullah Khaliqi, 26, a taxi driver who frequently travels through Taliban-controlled areas.

The Taliban here expresses allegiance to Mohammad Omar, the insurgency’s supreme leader, and is loosely aligned with the Taliban’s central command. It views the government as un-Islamic and a puppet of the West. But it otherwise shares little resemblance to its Pashtun brethren, who launched their revolt from the southern Afghan city of Kandahar.

The Taliban here is predominantly local, a mix of ethnic Tajiks and Uzbeks, according to provincial officials and Ahmedi, the former Taliban member, who was interviewed two days after defecting. It also includes a small contingent of fighters from neighboring countries.

Many fighters, like Ahmedi, were lured by the militants’ promise of salaries and food. Others are escaping the law or disputes with local officials. They also include disgruntled former mujahideen fighters who found no place within the government or the security forces.

Most were not even born or were children when the Taliban was created. That includes their top commander — Qari Fasihuddin — who is believed to be 27 or 28.

And while the Taliban has imposed Islamic law in areas it controls, it has also allowed schooling for girls, satellite television and music — all forbidden under Taliban rule. It gets most of its financing, Ahmedi said, by taxing opium farmers and extorting large sums of money from truck drivers ferrying gems and marble from nearby mines.

“They are not mullahs,” said Nayazee, referring to religious scholars. “They are not ideological Taliban.”

To be sure, the Taliban has become increasingly disjointed. Omar has not been seen in years, and some analysts suspect he is dead. Founding commanders have been killed in battle or have defected, creating power vacuums and competing factions.

A U.N. report last year said the Taliban is “experiencing a range of divisions driven primarily by differences over political strategy.” Those divides, it continued, were “amplified” by factions that had acquired control over various funding sources and were able to “behave with increasing autonomy.”

Several Taliban groups have launched independent Web sites and social-media platforms, including some that sympathize with al-Qaeda and its affiliates. Internal rivalries have led to assassinations of Taliban leaders, the U.N. report said.

In southern and eastern Afghanistan, some local Taliban commanders have banned polio vaccinations, fearing health workers were spies, even though the movement’s central command has approved the campaign.

“Which faction is in control of an area is an issue we face as we attempt to expand humanitarian access,” said Akhil Iyer, head of UNICEF in Afghanistan.

In Badakhshan, the insurgents admire the Islamic State, as well as Nigeria’s Boko Haram militancy, Ahmedi said. But they do not agree with their ultra-violent ways, he added. “The Taliban here are completely independent,” Ahmedi said. “. . . They are not taking orders from Pakistan, Mullah Omar or Kandahar.”

A warning

Noorulhuda, a police officer, remembers the day he was captured, his descriptions unwinding like a grainy film clip. The Taliban surrounding his outpost. The rockets raining from hilltops. The policemen dropping their weapons.

Then the walk at gunpoint, deep into the frigid mountains. Noorulhuda and his 24 kidnapped comrades had become emblems of the Afghan government’s weakness.

“I thought they would kill us,” said Noorulhuda, who like many Afghans uses one name, speaking three days after he was released.

If he were in southern or eastern Afghanistan, death would have been a certainty. The Taliban has killed thousands of Afghan security forces in the past year. Instead, Noorulhuda and his comrades were held for 47 days and fed three times a day, underscoring the operational differences between the Taliban here and elsewhere.

Once, Noorulhuda recalled, some of the foreign fighters beat them with the butts of their guns, and one yelled, “We should behead you guys!”

But, he said, local fighters prevented the foreigners from abusing them again, saying that they wanted to trade the officers for comrades and relatives being held by the provincial government.

Ahmedi offered another explanation: The local fighters, he said, disapprove of the beheadings carried out by some factions, viewing them as against Afghan codes, though the Taliban has long employed public executions.

“These Taliban think that the foreign hands are behind those Taliban who are executing security forces,” he said.

Eventually, tribal elders, who had relationships and ethnic ties with the Taliban, persuaded the insurgents to set them free.

But the militants issued a warning.

“They told us not to work for the government again,” Noorulhuda recalled.

As the Taliban presses, Adeeb, the governor, worries that the insurgents’ interest in his province goes beyond traditional goals of overthrowing the government.

Badakhshan’s mountains and forests provide an ideal haven for al-Qaeda and other foreign extremists. With Pakistan’s military staging operations to flush out Islamists across the border, Adeeb fears that more foreign fighters could seek sanctuary here.

“Once they get a foothold here, it will be impossible to remove them,” Adeeb said. “They can use it as a base to attack other Central Asian countries.”