In mid-October something interesting happened in Afghanistan. In Helmand province, the Pashtun heartland, U.S. Marines prepared to fight their way north as far as the strategically important Kajaki Dam. They expected a tough battle. Route 611, the main supply route, runs through country that in recent years has been crawling with Taliban fighters who desperately want to keep control of an important assembly area. I feared heavy casualties when we set out. But that didn’t materialize. The Marines met relatively slight resistance as they cleared and secured the road to the north. Most of the Taliban fled rather than fight.

Perhaps we should have expected it. The Taliban have taken a ferocious beating over the past year in what were once their strongholds in southern and southwestern Afghanistan. They are demoralized and finding it harder to resupply with men, money and weapons. The fighting campaign they boasted of this summer has been a flop. And that is because the troop surge by the United States and other NATO and international partners provided the military means to take on the insurgency and beat it.

All this does not, of course, mean that we have won. The picture in Afghanistan’s east, where we have put less effort, is less decisive. Plenty of work remains for us and our Afghan partners.

But make no mistake: Taliban commanders in Quetta and Peshawar have plenty to worry about. Nobody should think they are winning or can have any expectation of winning. The Afghan people don’t want them back. A recent, authoritative opinion survey by the Asia Foundation found that the number of Afghans who have no sympathy for the insurgents has risen from 36 percent in 2009 to 64 percent in 2011. That’s largely because, out of desperation, the Taliban are resorting to roadside bombs and suicide attacks that kill innocent Afghans. This is despite Taliban leader Mohammad Omar’s forlorn appeals to his military commanders, most recently in early November, to minimize casualties to Afghan civilians.

Furthermore, the Afghan army has added muscle: The days when army units could be beaten up by Taliban groups are over. NATO will need to continue the highly effective training program it began two years ago, but as I travel around Afghanistan I meet increasingly capable army and police units. Improvements in governance and the economy are also taking place, though more slowly than most Afghans would like.

All this is why we are able to progressively hand over security responsibility to our Afghan partners. The Afghan government announced the second phase of this transferSunday: About 50 percent of the country’s population live in areas coming under Afghan control.

We will finish this transition process by the end of 2014. It won’t be easy. To complete the training of Afghan forces, we will need sufficient troops to achieve the transition and continue to choke the insurgency through 2012 and 2013. But with persistence and determination, by 2014 we will be able to greatly reduce our commitment of money and troops, while achieving the right result.

After 2014, Afghanistan will still be a desperately poor country trying to recover from 30 years of conflict that destroyed institutions and infrastructure. Polls show that at a local level, Afghans are less concerned about poor security than they are about jobs, electricity and roads. The number of deaths from violence is shocking. But more tragic still is the number of children who die before their fifth birthday from avoidable illnesses.

The good news is that Afghanistan has huge mineral resources — oil, gas, copper, iron and rare-earth metals — that, in time, will allow its government to pay its bills. This is not sunny optimism. It is fact.

Until then, however, we should be willing to help pay for and train Afghanistan’s armed forces and offer development assistance. The cost will be a fraction of our present spending. And there is a lesson we should keep in mind: After the Soviet Union withdrew from Afghanistan in 1989, the Afghan government didn’t collapse, as many had predicted. But it disintegrated once the Soviets stopped their financial support.

This is a clear lesson. If we tighten the purse strings too early, we will risk all the gains we have made at such cost. That would mean a return to the security chaos that bred attacks on our countries. It would mean the uncontrolled proliferation of narcotics, a new wave of migration away from Afghanistan and turmoil in one of the world’s most sensitive regions. That is not an easy message when the economy is hurting. But the cost of greater instability in this part of the globe would be much greater than the price of our commitment after 2014.

An Afghan colleague pointed out recently that Afghanistan wasn’t always the war-torn country that we see in the news. It was once peaceful. And if we can bear the cost for just a little longer, it can be again. That would be good for Afghanistan and good for us, too.

The writer is NATO’s senior civilian representative in Afghanistan.