|US General John Allen, left, called the prison handover 'a step forward in our strategic partnership negotiations' [AFP]
The US military has signed a last-minute agreement to transfer its main detention centre in the country to Afghan control in six months time, a key step toward a long-term pact on Washington's military presence in Afghanistan.
The deal on Friday removed a sticking point that had threatened to derail talks between the two countries for a long-term partnership that is critical to defining the US role as it withdraws its troops.
The two sides have been in negotiations for months over a deal, and Afghan President Hamid Karzai had set a Friday deadline for the US to hand over the 3,000 Afghans it holds at its Parwan detention facility.
Friday's deal extends the deadline for handing over the detainees but for the first time spells out a US commitment to a hard transfer date.
Under the agreement, the US will still have access to Parwan and will be able to block the release of detainees it thinks should continue to be held.
Barack Obama, the US president, and Karzai discussed the stalled security pact talks on Thursday in a video conference.
Jay Carney, the White House press secretary, said the two leaders noted progress towards completing an agreement "that reinforces Afghan sovereignty while addressing the practical requirements of transition".
|Al Jazeera's Bernard Smith reports from the town of Pashtunzarghun in Herat province
The accord gives a boost to the stalled talks over formalising a role for US forces after NATO's scheduled transfer of security responsibility to the Afghan government at the end of 2014.
The detainees issue had been a major point of contention, as well as the still unresolved question of night raids by international troops on the homes of suspected militants, which have caused widespread anger among Afghans and which Karzai has demanded be halted.
Afghan and US officials have said that they want a strategic partnership agreement signed by the time a NATO summit convenes in Chicago in May.
General John Allen, the commander of US and NATO forces in Afghanistan, called Friday's deal a sign of real progress toward the larger partnership.
"This is an important step. It is a step forward in our strategic partnership negotiations," Allen told reporters in the capital, before signing the agreement alongside Abdul Rahim Wardak, the Afghan defense minister.
The new deal will put an Afghan general in charge of Parwan, a US-run prison adjoining its Bagram military base north of Kabul, within days, according to presidential spokesman Aimal Faizi, but will also give a six-month window to gradually transfer detainees to Afghan oversight.
According to the document, the US will continue to provide logistical support for 12 months and a joint US-Afghan commission will decide on any detainee releases until a more permanent pact is adopted.
The joint commission will have to come to a consensus on any such decision, according to US officials involved in the negotiations, a set up that will essentially give US officials power to block any releases they do not agree with.
Friday's memorandum comes as relations between the US and Afghanistan have become more tense in recent weeks following the burning of Qurans and other religious materials at the Bagram base, sparking riots and attacks that killed about 30 people.
The US-Afghan strategic partnership is expected to provide for several thousand US troops to stay and train Afghan forces and help with counter-terrorism operations.
It would outline the legal status of those forces, their operating rules and where they would be based.