Even the Turkmens, one of Afghanistan’s smallest and most isolated ethnic groups, began joining the Taliban in substantial numbers this year in four provinces across the north. It was a decision made largely because they were dissatisfied with their marginal representation in government, said Allah Nazar Turkmen, a member of Parliament.

Indeed, the local expression for joining the Taliban —“he went to the mountains” — hints at an act of protest, removing oneself from the government’s world.

Over the past few years, faith in the government and the warlords who were allied with the government, never strong, has rapidly diminished. Militias and Afghan Local Police forces installed by the American Special Forces were largely unaccountable. They extorted protection money from farmers, and committed rapes and robberies. But because they had guns and the backing of local strongmen close to the government, people’s complaints were ignored.

In Khanabad, a district southeast of Kunduz City, for instance, residents complained that the local militias were worse than the Taliban in part because while the Taliban would only demand payment once for a harvest, there was often more than one militia, each demanding its own share.

Over time, as villages threw their lot in with the Taliban, the insurgents’ cordon around Kunduz grew tighter. By last year the city felt so under siege that police officers were resistant to driving in a marked government vehicle for fear a Taliban fighter on a motorbike would slap a magnetic bomb on it.

But even as alarms started to be raised in Kunduz, there was a troubling bigger picture: Not just in the north, but all around the country, a campaign of steady and direct attacks on the Afghan security forces, who could no longer count on American support all the time, were taking a record toll.

That toll was sometimes described by American and Afghan officials as compelling evidence that the Afghan forces were fighting hard. But officials in places like Helmand Province in the south, and in Kunduz as well, described a pattern of worsening morale, and reluctance by troops and policemen to leave their posts.