It is not easy to find a constructive lesson from the Iraq war. If there is one, it is this: in war, you negotiate with your enemies, not your friends. One turning point in Iraq was the US-led effort to reach out to the "Awakening Councils", Sunni tribes who turned against al Qa'eda in return for political guarantees and financial incentives. It was not an ideal policy, but it did help to pull the country out of its spiral of violence.
Given the debacle that has been the 10-year campaign in Afghanistan, it is no surprise that it has taken so long to learn from the example.
In a televised speech on Saturday, the Afghan president, Hamid Karzai, confirmed officially for the first time that the United States is pursuing peace talks with Taliban members of the former regime in Kabul. The Americans have been quiet, but these talks have been a badly kept secret for quite a while. On Friday, the UN Security Council split the sanctions regime against al Qa'eda and the Taliban in an effort to open a breach between Afghan fighters and irredeemable terrorists.
Talks with members of the Taliban leadership are necessary - as distasteful as some will find a compromise. For the seven years that the Taliban held sway over most of Afghanistan, the regime crushed women's rights and conducted a bloody campaign against the country's Hazara minority, among other crimes.
The prospect that Afghanistan will return to that mire is unconscionable, particularly after 10 years of war. Paradoxically, the best way to avoid that is to include members of the Taliban in the political process.
While the Nato war has failed to secure territorial control, the civilian government in Kabul has floundered on another front. Mr Karzai has been called the "mayor of Kabul" because of his limited sphere of influence; since the 2009 presidential elections, even the capital is in doubt. In the military vacuum that will be left as the United States begins to withdraw, it is too much to hope that Kabul will control a unified country.
It would be a mistake to believe it is Mr Karzai or nothing. The Taliban should not be viewed as monolithic, terrorist entity indistinct from al Qa'eda. In a deeply religious country, amid fiercely independent tribal areas, militants who are now known as the "Taliban" will always be part of the political order. There are possibilities for a deal with many of these groups; others will be intent on dragging Afghanistan back to the dark ages.
It is an irony that the Taliban were less popular while they were in power in Kabul than they are now, fighting foreign forces. Afghans face a difficult path ahead, but the fate of their country should be in their hands.