The election in Afghanistan has turned into a disaster for all who promoted it. Hamid Karzai has been declared re-elected as President of the country for the next five years though his allies inside and outside Afghanistan know that he owes his success to open fraud. Instead of increasing his government's legitimacy, the poll has further de-legitimised it.

From Mr Karzai's point of view he won through at the end and showed that nobody is strong enough to get rid of him. For the US President, Barack Obama, the election has no silver lining. It has left him poised to send tens of thousands more US troops to fight a war in defence of one of the world's most crooked, corrupt and discredited governments. "It is not that the Taliban is so strong, but the government is so weak," was a common saying among Afghans before the election. This will be even truer in future.

The US and its allies may now push for a national unity government between Mr Karzai and Abdullah Abdullah, his main rival for the presidency. This might look good on paper, or at least better than the alternative of Mr Karzai ruling alone. But enforced unity between men who detest each other will institutionalise divisions. Its value will largely be in terms of propaganda for external consumption.

Download the new Independent Premium app Sharing the full story, not just the headlines

On 4 November 2008, when Mr Obama won the US election, he must have believed he had been right to take a soft line on Iraq and a hard one on Afghanistan. The former looked much the more dangerous place. Just 12 months later he is discovering that the reverse is true and Afghanistan is the biggest foreign policy problem facing the US. It is a more dangerous place for the US and its allies than Iraq ever was.

In Iraq, unlike Afghanistan, the government was democratically elected by a huge majority in 2005. There was a savage civil war because the fifth of the population, who are Sunni Arabs, did not accept that victory. The Shia did not relish US occupation, but they were prepared to co-operate with it while they took power. Only the Kurds were long-term US allies.

In Iraq the state was previously strong and can be made strong again. Above all the Iraqi government had money. Its oil revenues were $62bn (£38bn) last year. The Afghan government has in the past had limited authority outside the cities and it has no money apart from foreign aid handouts.

Another important difference between the two countries is geography. Iraq is flat outside Kurdistan and the great majority live in cities and towns on the Tigris and Euphrates. It is not good terrain for guerrilla fighters in contrast to Afghanistan with its high mountains, broken hills and isolated villages.

The Taliban have been able to use safe havens in the Pashtun belt of north-west Pakistan. These areas are now under attack from US drones and the Pakistani army. But the suicide bombers who killed 35 people in Rawalpindi and maimed at least seven in Lahore yesterday showed that the cost to Pakistan of attacking an insurgency firmly rooted in its Pashtun community will be high.

One of the few benefits of the Afghan election might be a more realistic understanding in the US and Europe – particularly in Britain – of the mechanics of Afghan politics. These were eloquently summarised in his resignation letter to the US State Department by Matthew Hoh, the senior American civilian representative in Zabul province. He was previously a US Marine officer in Iraq. Mr Hoh makes the important point that the US has joined one side in what is effectively a 35-year-long civil war in Afghanistan. He sees this as being between the urban, educated, secular, modern Afghanistan against the rural, religious, illiterate and traditional Pashtun.

"The US and Nato presence and operations in Pashtun valleys and villages, as well as Afghan army and police units that are led and composed of non-Pashtun soldiers and police, provide an occupation force against which the insurgency is justified," concludes Mr Hoh. "I have observed that the bulk of the insurgency fights not for the white banner of the Taliban, but rather against the presence of foreign soldiers and taxes imposed by an unrepresentative government in Kabul."

Mr Hoh's observations are confirmed by opinion polls in Afghanistan. The majority of Afghans do not want more foreign troops. They think their arrival will mean more dead Afghans. The areas where the Taliban is most acceptable is where US and allied planes and artillery have killed civilians. The idea that the US Army is going to turn into a glorified Peace Corps is romantic and unrealistic.

Washington and London should really wonder after Afghanistan's farcical election if their political and military investment in the country is worth it. Their policy of propping up and strengthening the central government looks more ludicrous than before. There is something sickening when British troops had their legs blown off securing polling stations where Afghans could vote, when the British-supported government in Kabul was busily fabricating the vote so the presence or absence of polling booths was entirely irrelevant.

The US and Britain have joined somebody else's civil war. It is not one that the Taliban are likely to win, because they rely on the Pashtun community which makes up only 42 per cent of the population. By the same token they are not likely to lose either. American troop reinforcements would give the anti-Taliban forces control over more of the country but would also intensify the war. The context of greater US involvement will be, thanks to the election, a weaker Karzai government so Americans, not Afghans, will take the vital political and military decisions. To Afghans this means the foreign presence will look even more like an imperial occupation.