Enthusiasts for the catastrophe that is the Iraq war may be hard to come by these days, but Afghanistan is another matter. The invasion and occupation that opened George Bush's war on terror are still championed by powerful voices in the occupying states as - in the words of the New York Times this week - "the good war" that can still be won. While speculation intensifies about British withdrawal from Basra, there's no such talk about a retreat from Kabul or Kandahar. On the contrary, the plan is to increase British troop numbers from the current 7,000, and ministers, commanders and officials have been hammering home the message all summer that Britain is in Afghanistan, as the foreign secretary, David Miliband, insisted, for the long haul.

"We should be thinking in terms of decades," the British ambassador, Sir Sherard Cowper-Coles, declared; Brigadier John Lorimer, British commander in Helmand province, thought the military occupation might last more than Northern Ireland's 38 years; and the defence secretary, Des Browne, last week confirmed that the government had made a "long-term commitment" to stay in Afghanistan to prevent it reverting to a terrorist training ground. Even allowing for the Brown government's need for political cover if it is indeed to run down its forces in Iraq, that all amounts to a pretty clear policy of indefinite occupation - one on which it has not thought necessary to consult the British people, let alone the Afghans.

All this follows the escalation of Britain's involvement in Afghanistan last year, when Browne's predecessor, John Reid, sent thousands of extra troops to the south to "help reconstruction", hoping they would be a able to leave "without firing a single shot". Two million rounds of ammunition later, what was supposed to be a peacekeeping mission is now an all-out war against a resurgent Taliban that has become an umbrella for Pashtun nationalists, jihadists and all those determined to fight foreign occupation. British casualties have risen sharply - seven have been killed in the past month - along with those of other western forces, while the public at home is increasingly fed a media diet of Kiplingesque deeds of derring-do by "our boys" on the front line. And in a telling echo of the claims that have punctuated each phase of the Iraq disaster, Browne last week said he detected a "turning point" in the British campaign to "bring stability" to Afghanistan.

For Afghans, six years after they were supposed to have been liberated, life is getting worse. As the International Committee of the Red Cross reported two months ago, the humanitarian situation is deteriorating and civilians are suffering "horribly" from growing insecurity and violence in an increasingly dirty war. The fighting in the south has driven 80,000 from their homes, and the civilian casualty rate has doubled over the past year: more than 200 were killed by US and other Nato troops in June alone - far more than are estimated to have been killed in Taliban attacks. The savagery of indiscriminate US aerial bombardments provoked violent demonstrations and is widely seen as having increased support for the Taliban's armed campaign.

Given the manifest failure of the occupation to bring either peace or development to Afghanistan, it's not immediately obvious why it's still considered by some to be a good war - though a majority of Britons, Canadians, Italians and Germans, it should be said, want their troops withdrawn. Partly it must be the fact that the original invasion was launched in response to the 9/11 attacks - which turned out to have been at least partly coordinated from al-Qaida's Afghan camps - and had some measure of UN acquiescence (even if the relevant resolutions didn't actually mention Afghanistan). Added to that is the oppressive and obscurantist record of the Taliban regime and the elite fear that military failure will fatally undermine the projection of western power in future.

But by intervening on one side of an ethnically charged civil war to overthrow the Taliban - rather than, say, targeting special forces against al-Qaida - the US and its allies ended up exchanging warlords for theocrats and turning most of the country into a collection of lawless and brutal fiefdoms. Instead of al-Qaida terror networks being rooted out, they were allowed to migrate to the borderlands, Pakistan and Iraq; Osama bin Laden, whose capture was the first aim of the war, escaped; and the limited expansion of women's and girls' freedoms in Kabul and a few other urban areas was offset by an eruption of rape and violence against women. Western politicians like to describe the Afghan government as democratically elected, when in fact the elections were marked by large-scale fraud and intimidation in polls that gave regional warlords pride of place, while political parties were not allowed to take part. In real life, occupied Afghanistan is, as the UN warned last year, a failed state, which now produces 90% of the world's opium and where corruption and insecurity have sunk reconstruction.

Of course there was a time, in the 1970s and 1980s, when girls were encouraged to go to school and university in Afghanistan, women accounted for almost half the country's teachers and civil servants and the government redistributed land to the rural poor. But the US spent billions of dollars to destroy it in a cold war coup de grace and laid the foundations for the jihadist Frankenstein of al-Qaida in the process. Gordon Brown now claims Afghanistan is "the frontline against terrorism". In reality, the key to the al-Qaida threat lies in Pakistan and Saudi Arabia and the dictatorial regimes the west sponsors there, while its support is fuelled by the occupations of Iraq, Afghanistan and the Palestinian territories.

Britain is now fighting its fourth war in Afghanistan in 170 years, and might have learned by now that you cannot impose a government from outside against a people's will. Earlier this summer the Afghan senate called for a date to be set for the withdrawal of foreign troops and negotiations with the Taliban, as did the Pakistani foreign minister, Khurshid Kasuri, this month. There will be no peace or stability in Afghanistan while foreign troops remain, and a wider settlement will surely have to include the Taliban and regional powers such as Iran and Pakistan. Unfortunately, politics dictates that a great deal more blood is likely to be shed on both sides before that comes to be accepted.

s.milne@theguardian.com