Kabul: A last-minute agreement has been reached on how to handle the transfer of US detention facilities in Afghanistan to the Kabul government, Afghan and Western officials said on Friday.

The issue has threatened to derail a long-term partnership between the two countries. They are in negotiations to formalise a role for US forces after NATO's scheduled transfer of security responsibility to Afghanistan at the end of 2014.

Afghan President Hamid Karzai set Friday as the deadline for handover of control of the Parwan detention facility, a US-run prison that holds about 3,000 detainees, most of them Afghan citizens.

Earlier, Afghan officials indicated Karzai would accept an American proposal to delay the transfer for six months in the framework of an agreement, but it was not clear if Karzai agreed with that.

Parwan is the largest of the facilities, located next to the sprawling Bagram military base near Kabul, the capital. The US previously handed over responsibility for a few hundred detainees there but said the Afghan government was not ready to take over running the full detention centre.

Afghan Defence Minister Gen Abdul Rahim Wardak and US Gen John Allen, the commander of NATO and US forces in Afghanistan, will sign a memorandum later in the day, the Afghan Foreign Ministry said in a statement.

The Ministry did not say what the memorandum covered, but a Western official confirmed that it was about the transfer of detention facilities. The official said the exact wording of the agreement was still being discussed, but the major issues have been decided.

The official declined to give other details and spoke anonymously because the document is still being finalised.

An Afghan official confirmed separately that the agreement was about detention issues but declined to give more details. The official spoke anonymously to avoid giving details until the document is made public.