There is a lot of bad blood around right now in Afghan politics.

Where once there was a semblance of harmony between President Hamid Karzai and his international allies, there is now persistent rancour.

That this relationship has become increasingly rocky was further highlighted this weekend as US Secretary of State John Kerry and Karzai continued to wrestle with differences over the terms of a future US military presence in Afghanistan after the 2014 scale-down of troops from Nato's International Security Assistance Force (ISAF).

The bad feeling between Karzai and Kerry was worsened by a US State Department announcement that American troops had captured Latif Mehsud, a leader of the Tehrik-e-Taliban Pakistan terrorist group. The operation was not to the president's liking.

Mehsud was returning from a meeting with Afghan intelligence officers to discuss swapping prisoners and it has been suggested that the Afghans were trying to recruit him as a go-between for peace talks.

Aimal Faizi, a spokesman for the Afghan government, said: "The Americans forcibly removed him and took him to Bagram."

This latest fall-out between Karzai and his allies comes in the wake of the president criticising Nato's campaign on the BBC, accusing it of causing "a lot of suffering" and making "no gains".

This rise in discontent all comes as preparations for the international military scale-down and handover gains pace. Such handovers are usually poignant affairs and last week's parade at Camp Bastion was no exception. Britain's 1st Mechanized Brigade prepared to go home after seven months while out went the battle-hardened veterans of the 7th Armoured Brigade, the world-famous Desert Rats, and in came the new draft - bright-eyed and bushy-tailed.

The old flag was lowered and the new version raised. Senior officers cut sharp salutes, bugles sounded and a lone piper added his tunes of glory. So far, so usual for the British Army, which has seen it all before in recent years, from Northern Ireland to Iraq and Afghanistan. Only it was different this time because, if everything goes according to plan, it could be the last time.

When the Desert Rats end their deployment in Afghanistan next summer and Operation Herrick 16 winds down, all combat operations in Helmand province will be at an end and the Afghan security forces will be responsible for their country's destiny, leaving the British Army free to return to UK garrisons from Tidworth on Salisbury Plain to Fort George in Inverness-shire.

That it is the end of an era was made clear by the 1st Brigade commander Brigadier Rupert Jones, son of the Lieutenant-Colonel "H" Jones, the 2nd Parachute Regiment commander who was awarded a posthumous Victoria Cross at the Falklands in 1982. The brigadier had not only words of praise for his own men, highlighting their forbearance and professionalism, but he also commended the Afghan security troops who were on parade with them. They were the future, he said, and had shown what could be done when they had taken the lead in the summer campaign against the Taliban. Then, in a carefully scripted remark, Jones went on to say that everyone in Afghanistan, whatever their nationality, should take pride in the work of every soldier who had served in the ISAF.

"What I hear from local Afghan commanders and governance leaders is that they recognise the job that ISAF have done here for them," he told those assembled on parade, "that the situation has been transformed but, importantly, that they are now ready to take forward the mantle."

His message to the parade was clear: people back home and in Afghanistan care about what is happening in Helmand province and they want the soldiers, whether Nato or Afghan, to know that.

His comments were timely not least in coming after Karzai's critical remarks to the BBC about the Nato operation. It is inconceivable that Jones did not choose his words carefully: Karzai's comments annoyed many in the British Army, which has suffered 444 casualties in seven years of almost constant combat against the Taliban. A quiet, intelligent man with an instinctive compassion for his men of the 1st Mechanised Brigade, under his leadership they have enjoyed a successful tour of duty mentoring the Afghan security forces to allow them to take a greater share of responsibility for mounting operations in the field.

Karzai's barbed comments caused bewilderment in Nato military circles. Not only were they seen as unhelpful in themselves but they also came at a tricky time in Afghanistan's relationship with the West. At the end of this month the deadline arrives for Afghanistan's government to reach consensus with the US for the signing of a Bilateral Security Agreement (BSA), which will keep American forces in the country beyond the withdrawal date of December 2014.

If that does not happen - and this weekend the signs are not good - then US diplomats have warned that they will advise President Barack Obama to write off Afghanistan as a bad job to enable Washington to concentrate on security threats elsewhere in the world. At present, there are 87,000 Nato personnel in Afghanistan - 52,000 of whom are American - and the BSA plan would enable a residual garrison of 10,000 American anti-terrorism specialists to remain in the country for an unspecified period.

However, two sticking points have been raised by Karzai's government. The main one is an Afghan insistence that the US would come to their aid if they were attacked by a foreign power, the inference being that the potential enemy would be neighbouring Pakistan. The second is a demand for US assurances that their military specialists would not undertake counter-insurgency operations that might cause the deaths of Afghan civilians. According to a US military source, both conditions are impossible to keep, "the first because Pakistan is a US ally and no-one can give an open-ended commitment which might end in hostile operations". The second is more controversial, he says, because in counter-insurgency warfare "collateral damage is always a possibility".

As other Nato allies, notably the UK, have promised to join the US in committing forces after next year's withdrawal, the problem is wider than a spat between Washington and Kabul. If no agreement is reached no other member of the alliance will honour their obligations and that absence would be a blow to Afghanistan's plans for managing security once Nato has departed. Germany has already indicated it will not commit the 800 soldiers it had promised.

It all hangs on which way the US decides to jump. Last week, President Obama gave the strongest indication yet of which direction that leap might take when he announced that while he was prepared to order the deployment of forces after the conflict formally ends he suggested that if no agreement is reached, he would be comfortable with a full withdrawal of US troops. By way of response, Karzai said that he could not make any announcement until the whole question had been debated by tribal elders and that no such meeting had been scheduled until November, well after Obama's deadline.

Inevitably, there is an element of brinkmanship in the negotiations but some idea of the urgency felt by Washington was signalled on Friday through John Kerry's surprise visit to Kabul to hold talks with Karzai. The deal had been struck in a telephone conversation between the two men last week and, unusually, Kerry then cleared his desk to fly with his team to Kabul. According to those on the plane, the mission is seen as "doable and desirable" and the fact that the meeting is taking place at all is a sign of the need to reach agreement before the end of the month. "That's why we're pressing," said one of the officials travelling with the Secretary of State.

No one is expecting a cut-and-dried agreement to be achieved this weekend but there is an expectation that talks will continue between officials from both sides. One thing is certain: there is a growing diplomatic need to repair the relationship between the Kabul government and its main Nato allies. Last week's outburst by Karzai was only the tip of the iceberg as regards discontent. While his criticism of Nato's tactics was insensitive and an affront to the 3389 lives lost, there is a growing sense on both sides that Afghanistan is facing a watershed next year.

Not only will Nato forces be leaving, but the country is scheduled to hold presidential elections that Karzai will not be contesting, having already served for 12 years. To date, 27 possible candidates, including Karzai's brother, have filed papers to stand and the final shortlist will be announced next weekend. Officially at least, the Taliban will not be contesting the elections, which they have written off as "a waste of time", but US security sources acknowledge that among the men running for president and vice-president will be "a motley collection of warlords, tribal chiefs, current power players, and hangers-on".

When the elections happen next year, the position taken by the Taliban will be some indication of how far the country has come. Most counter-insurgency experts are agreed there can be no lasting solution without their participation and some moderate tribal leaders may hedge their bets and decide to take part when the time comes. Two former warlords announced last week that they will run on a joint ticket. Abdul Rab Rasoul Sayyaf, an influential lawmaker and religious scholar, registered his candidacy for the presidency, while his running mate for the vice-presidency will be Ismail Khan, who has already served a term as energy and water minister.

Not that there are many hopes that a corner has been turned. The official line was expressed by Taliban leader Mullah Muhammad Omar at the end of August in his Eid al-Fitr address, which commemorates the end of the holy month of Ramadan. It was another hard-line rant in which he vowed the Taliban would continue to attack foreign forces and support only a fully Islamic government. Not surprisingly, he denounced Karzai's government as western "hirelings" and urged Afghans not to work with them.

While Mullah Omar also repeated orders to his followers to avoid tactics such as suicide bombs and kidnapping, which cause civilian casualties, the reality is that many Taliban groups are beyond his control and wage unrestricted warfare within the country. That lack of unified leadership and the knowledge that Taliban groups act at will across the border with Pakistan are the main reason why Karzai's government is nervous about US intentions in keeping a security presence in the country after next year's handover.