There is not one war in Afghanistan. There are three.

First, there is the fight against al-Qaeda and related terrorist groups. Second is the war to protect and support the fledgling Afghan government against the Taliban insurgency. The third war is the least understood but the most enduring: the internal social and cultural battle between the urban modernizers of Afghanistan, mostly based in Kabul, and the rural, tribal, anti-modern peoples who live in the country’s inaccessible mountain regions.

In eastern Afghanistan’s Konar province, particularly in the Pech Valley, these three wars have intermingled, revealing the limits and possibilities of U.S. strategy. And as the nation reassesses its approach to Afghanistan with the death of Osama bin Laden, the reassignment of Gen. David Petraeus to the CIA and President Obama’s summer deadline for beginning a troop drawdown, the Pech offers unique insights on this third war — and how to avoid being drawn into more versions of it.

When American forces pushed into Konar’s Pech, Korengal and Waygal valleys in 2006, counterinsurgency was the brilliant new U.S. strategy that promised to turn around a faltering war. Well-meaning commanders and their advisers built more than 40 bases there, constructing roads to share the benefits of civilization with the region’s tribes. The people would then be secured and controlled by the Afghan government, the plan went, making it difficult for al-Qaeda and other terrorist groups to operate nearby.

This month, however, the last U.S. forces will close their bases and withdraw from the Pech Valley. These are the final troops to leave the northern Konar valley complex — made famous by the 2010 film “Restrepo” — marking the end of a five-year effort to extend the central government’s influence to these isolated regions. The outgoing U.S. commander of forces in eastern Afghanistan, Maj. Gen. John Campbell (with whom I worked as counterinsurgency adviser), made perhaps the most understated comment about the Pech when he once quipped, “It is different than other places.”

Perhaps a better strategy — better than the one that has cost more than 100 U.S. military lives and billions of dollars in that valley alone — would have been to let it stay different.

Mountainous regions throughout the world tend to be refuges for those who have opted out of mainstream society, whether voluntarily withdrawing or fleeing from real or perceived oppression. There are the Kurds in Turkey; the Karen, Wa and Lisu minorities of Burma; and the Scotch-Irish of the Appalachians. They live in the hills precisely because the terrain is, or was until recently, an undesirable place for the state to incorporate. They believe that integration into a state means slavery, corruption, taxation, conscription and immorality — and an end to their way of life.

In Afghanistan, such traditional groups — the Korengali, the Nuristanis and the more isolated tribes of Pashtuns — have been waging a generations-old conflict with the Kabul-based modernizers, and political control and family life have been the main points of dispute. For example, the 1929 Afghan civil war began when the Shinwari Pashtun tribe attacked the provincial capital of Jalalabad to protest new laws that challenged local traditions and family life, most notably the status of women, and attempted to impose taxation. These groups are proudly unassimilated into the larger structure of Afghan civilization, such as it is.

America’s counterinsurgency strategy did not go poorly at first, and its supporters highlighted the progress made in Konar in 2006 and 2007. Even traditionalists appreciate some of modernity’s advantages. What isolated chieftain doesn’t like hard currency, and who doesn’t prefer easier export of local products, whether food or gems or timber, to urban centers?

But roads run in two directions, and the same vehicles that are welcome to leave full of local goods are more suspect when they arrive with artifacts such as CDs and printed T-shirts, let alone government agents or tax collectors. So while there may have been some initial local enthusiasm about modernization coming to the Pech Valley, residents’ five years of active resistance should be considered their final answer.

U.S. forces set out to assimilate them to the Kabul government, inadvertently aligning themselves with one side in the third war. Local elders rejected the presence of the Americans and, by extension, of Kabul. Perversely, this may have tightened links between terrorist groups and local tribes, which united to repel U.S. forces. Base by base, the Americans were forced to leave the side valleys, with the battles of Wanat and Kamdeshthe most notable moments in this campaign. And while U.S. troops were not pushed out of the Pech, the lack of progress and overall hostility made it clear that Campbell made the right decision to withdraw.

These remote regions where the Afghan state is weak are precisely where transnational terrorists tend to congregate. This is why strengthening failed states is a core tenet of the U.S. national security strategy. Does the failure of counterinsurgency in the Pech Valley mean that this tenet must be abandoned? Must the United States accept terrorist strongholds in remote areas?

Certainly not. In retrospect, the attempt to extend the state’s authority into the Pech was folly. Kabul’s nascent government, struggling with corruption and basic competence, will not be able to administer the Pech for a generation. Instead, weak states should limit their reach while increasing their capabilities in areas they already control. They should develop more integrated economies in core urban areas and improve the schools near the cities and on the roads between them. Or as I once heard it put, let’s focus on those who want to join civilization and leave alone those who are in active rebellion against it.

In fact, the strategy of Campbell and the regional command’s senior civilian representative, Tom Gibbons, provides the proper model. In July, Campbell and Gibbons published a concept for a “district reinforcement program.” It pushed U.S. troops, money and attention to key district centers along the roads connecting the major cities in eastern Afghanistan. These efforts were intended to connect Kabul with traditionally tributary cities — Jalalabad, Asadabad, Ghazniand Gardez — and create a safe zone at each district center where police and civil servants could be trained, where commerce could thrive and where solar power plus cellphone and Internet connectivity could help build infrastructure. Though obtaining proper resources has been a struggle, the effort is bearing fruit in many such districts.

The Pech will not be ignored. The U.S. military will continue to hunt down terrorists there and in a host of other valleys. What it will not do is attempt to remain in these remote regions, attempt to alter the way of life of their people or attempt to extend the reach of Kabul into places where it is decidedly unwelcome. That is an exercise in futility, a lesson the troops withdrawing from the Pech have paid in blood to learn.

The failure in the Pech does not mean that counterinsurgency is a failed concept. But it shows that it certainly will fail — or be exponentially more difficult — when it is attempted against isolated peoples who have consciously opted out of the state system.

Yes, these non-state spaces do leave room for terrorists to find sanctuary. But it’s awfully hard to attack Manhattan from the Pech Valley.

Douglas Ollivant, a retired Army lieutenant colonel, has served in Iraq and Afghanistan and on the National Security Council for the Bush and Obama administrations. He is now a senior fellow in national security studies at the New America Foundation.