With two weeks left of his diplomatic career, Sir William Patey could be forgiven for being discreet. Instead, as he sits in his office in Kabul, the British ambassador to Afghanistan is undiplomatically frank about what he sees as the errors and failings over the past decade.

Principal among them is the decision to invade Iraq in 2003, taken less than two years after Britain, America and an alliance including Australia and France went into Afghanistan to depose the Taliban.

Sir William told The Sunday Telegraph that both Washington and Downing Street wrongly assumed that the war was “won and the Taliban had run away”. But that led to a long-running problem: “years of missed opportunity” followed because the focus was on Iraq instead of Afghanistan.

The 58 year-old said the opportunity to train and equip the Afghan National Security Forces to fill the power vacuum was missed, allowing the Taliban to return. “We were too focused on Iraq and we took our eye off the ball. We thought we had won [in Afghanistan] and the Taliban had run away and we just sort of left it to the Afghans to get on with it and we very quickly switched our focus to Iraq. You don’t normally write history so quickly but I’m pretty clear that we won’t have to wait too long for history to make that judgment.”

Speaking the day before six British soldiers were killed in Kandahar, the ambassador also suggested that the presence of International Security and Assistance Force (ISAF) had become a hindrance to the stability of the country.

Asked if foreign troops were now part of the problem, Sir William responded: “Could be”, adding: “Afghans have never been comfortable with foreigners and there comes a point — no matter how benign the intentions, and how much you explain that this [ISAF] is not an occupying force, that we are here under a UN mandate agreed with the Afghans — when you just outstay your welcome.”

But he said that ISAF now had a transition plan which, once complete in 2014, would mean the Afghans will be fully responsible for the security of Afghanistan.

He went on: “It will be very difficult for the Taliban to argue they are fighting a foreign invader when the people on the streets are their own police and army.”

The ambassador also said the role of British and ISAF troops had changed in the past few years and was less about killing the Taliban and more about “buying time”.

Sir William has risen to the top of the diplomatic service while shattering the stereotypical image of the Eton-educated diplomat.

He was born in Edinburgh, speaks with a thick Scottish accent, is grammar-school educated and went to Dundee University where he read history. His language is often colourful and his off-the-record assessments of certain public individuals are accompanied by howls of mischievous, throaty laughter.

For the next two weeks he will be in charge of Britain’s biggest embassy before retirement beckons. Despite his criticism of the Labour government’s past failings, he believes the country will have a bright future providing the West does not lose interest in Afghanistan’s development.

He added: “Afghanistan will be a mess for many years to come, but it will be an improving mess”, he says, smiling. “There is one end of the scale where we leave, the Afghans bicker amongst themselves, the Taliban don’t sign up to negotiations and there is internal strife. I don’t think that’s the most likely, but it is within the range of possibilities just as it is that the Afghans get everything right.”

Pointing to past failures when the Russians were in charge, he adds: “The reason why the Afghan National Army (ANA) fell apart in the 1990s was not because the Russians had left, but because they had stopped paying and that’s when the warlords came in and started fighting amongst themselves.

This latest plan has learnt the lessons of history. Under the Russians, the ANA was a large force but lacked quality, so what we have to do is concentrate on the quality because we have the numbers.

“You ask me what the biggest risk to the success of our strategy is? Well, it’s us. It is the West being diverted somewhere else or the international community not being prepared to ante up the money.”

But Sir William said that Afghanistan could not expect endless unconditional funding from the international community. “It is important that Afghanistan continues to make progress on reinforcing democratic institutions, having free and fair elections, and there is no regression in human rights.

"So it’s not just, 'Here’s a pile of money for 10 years’. We don’t expect Afghanistan to have eliminated corruption, but we do expect to see some improvements.”

He said the annual cost of running the Afghan security forces would be around £2.62 billion, the vast majority of which would have to be found by Western governments. Such decisions, he said, would be decided at the Nato summits in Chicago and Tokyo later this year when members of the international community disclose their future commitment to the development of the country.

But Sir William also believes the Taliban must play a part in the country’s future if peace is to stand any chance. He said: “Our preference is for the Taliban to reintegrate and reconcile. Nobody has objected to the Taliban becoming a political party, nobody has objected to the Taliban taking part in politics or holding government positions or district-level positions if that’s how it turns out.”

In two weeks’ time the Foreign Office will lose one of its most capable and influential diplomats. But the pipe and slippers will have to wait. “I hope to enter the private sector — I still have some time to give.” And the inevitable biography? “That will have to wait for about five years.”