Hamid Karzai, furious at being sidelined from Afghan peace talks, has thrown his government into yet another dramatic confrontation with the international community by demanding the US hand over control of its main military prison in Afghanistan.

Officials at the US embassy and Nato headquarters in Kabul scrambled to deal with the unexpected announcement, which comes amid humiliation for Karzai over US efforts to set up an overseas political office for the Taliban despite the minimal involvement of the Afghan government.

Karzai said a commission had been established to oversee the transfer, within a month, of the detention centre at Parwan, which replaced the old prison at Bagram airbase, north of Kabul. Bagram became infamous during the "war on terror" for holding the most "high-value" Taliban and al-Qaida detainees.

The shock announcement coincided with the parading at a press conference of two British private security workers who were arrested in Kabul on Wednesday with a car full of undocumented assault rifles. The government said the two men would be charged for illegal gun running and their company, a Canadian organisation called GardaWorld, would be closed.

Although the US has long agreed in principle to transfer its military prisons to Afghan control, the timetable has repeatedly slipped. The new deadline set by Karzai will be impossible to meet, not least because of grave concerns among the international community about the way Afghanistan treats the prisoners it already has responsibility for.

A UN report in October found that torture was rife in some Afghan prisons, including of inmates that had been transferred from Nato custody.

The Afghan government, however, has drawn up its own report on Bagram that Karzai said detailed "many cases of violation of Afghan constitution and other applicable laws of the country, the relevant international conventions and human rights".

A senior western official closely involved in detention issues said the US was concerned that Afghan guards would have trouble maintaining the equipment at the new Parwan detention facility

Nonetheless, Karzai has been adamant his government should gain complete control over all Afghan prisons, including Bagram and the issue has been one of the key sticking points in negotiations between Washington and Kabul over a much-delayed strategic pact that will determine the US role in the country after 2014.

"It's classic Karzai off his meds moment," said one western official in Kabul, alluding to a long track record of behaviour the international community has regarded as highly erratic.Karzai has successfully deployed such brinkmanship before, not least in August when he stunned the diplomatic corps by ordering that tens of thousands of private security guards should be disbanded within four months. A compromise was eventually reached that will lead to greater government oversight of private security contractors.

Last month Karzai withdrew his Qatari ambassador to express his anger at the plans. Although Karzai has long favoured political efforts to bring the war to an end, he has insisted that it be controlled and organised by his government. The Taliban think otherwise. In a statement released this week announcing its willingness to set up an office the movement made no mention of the Afghan government whatsoever.

It said the only two parties to the conflict of any importance were the US and the insurgents themselves.

Nato's International Security Assistance Force and the US embassy declined to comment.