* Call comes after start of complex US-Afghan talks
* Karzai says continued detention violates agreement
Afghanistan's president on Wednesday demanded the release of dozens of prisoners from U.S. custody and said all inmates held in breach of an agreement must be transferred immediately to Afghan authorities.
Hamid Karzai's call for "urgent actions" by Thursday came days after the start of complex bilateral talks on a security pact on the role the United States would play in Afghanistan after most of its troops are withdrawn by the end of 2014.
Karzai's demands follow a meeting with top defence, police and legal officials who inspected Bagram prison and concluded the United States had violated an agreement governing the transfer of the jail to Afghan control.
He issued a statement giving the United States until Thursday to act swiftly to "set free all the inmates that need to be released as per Afghanistan applicable laws" and hand over any prisoners who were captured by U.S. forces after the bilateral agreement had been signed.
Washington turned over the high-security prison and around 3,000 suspected Taliban fighters to Afghan control in a six-month period that ended on Sept. 10, with a grace period of two months. The sprawling prison has been likened to Guantanamo in Cuba and Abu Ghraib in Iraq because of allegations of serious abuses of detainees.
Karzai's spokesman, Aimal Faizi, said on Monday that more than 70 detainees who had been cleared by Afghan courts were being wrongfully held by U.S. authorities.
The row could complicate already thorny negotiations over the future U.S. military presence in Afghanistan, which includes technical issues such as visas and whether foreign troops would be immune from prosecution in Afghanistan.
The prison deal took almost a year to finalise and had paved the way for discussions on the U.S. status-of-forces role. Some critics say Karzai is pushing the prison issue hard as a means of strengthening his own hand in the negotiations.
His spokesman Faizi said "administrative detention", a term used by the United States to describe suspects deemed security threats who are held without charge, did not exist under Afghan law and was therefore illegal.
"There are some prisoners found innocent by the court are still in custody. This act is a serious breach of a memorandum of understanding," Faizi told reporters on Monday.