KABUL  - US Secretary of State John Kerry held a second round of talks with Afghan President Hamid Karzai in Kabul on Tuesday after the two put on a public show of unity in a bid to repair damaged ties.

Kerry visited Afghanistan as the United States ceded to a key long-standing demand of Karzai by delivering full control of Bagram prison, where Taliban and Al-Qaeda suspects are held north of Kabul, to Afghan forces.

Karzai had turned the fate of Bagram and its hundreds of detainees into a rallying cry for his push to take back sovereignty as the bulk of US-led combat troops prepare to leave by the end of 2014 after more than a decade of war.

After a series of fiery anti-US outbursts from Karzai in recent weeks, both he and Kerry were keen to make a public display of friendship and stress that relations were back on track. “Bagram prison was handed over to the Afghan government... Finally after many years of effort we have reached a deal,” Karzai told reporters at a joint press conference late Monday.

Kerry said: “The US is committed to an enduring partnership... The US supports a strong and united Afghanistan. “We are committed to Afghanistan’s sovereignty and we will not let Al-Qaeda or the Taliban shake this commitment.”

Earlier this month, Karzai accused Washington of working in concert with the Taliban and his spokesman described the Nato coalition’s war effort as “aimless and unwise”, triggering fury from Afghanistan’s foreign backers.

Responding to a storm of protest over the collusion allegations, Kerry said he was confident that Karzai “does not believe that the United States has any interest except to see the Taliban come to the table to make peace”.

For his part, Karzai said: “I was interpreted as saying the US and Taliban are colluding, but I did not use this word.”

Afghan forces are gradually taking on responsibility for battling the Taliban as most of the 100,000 foreign troops prepare to exit by the end of 2014.

Karzai is due to step down at elections next year, 13 years after he came to power with US backing when the hardline Taliban regime was ousted in the aftermath of the September 11 attacks of 2001.

During his trip, Kerry emphasised the importance of a credible poll in 2014, and paid tribute to Afghan lawmakers, rights activists and election officials. “You’re engaged in a remarkable effort and the whole world is watching,” he told them on Tuesday before he flew out of Kabul.

The war in Afghanistan is increasingly unpopular in the United States, and the latest outbursts from Karzai led many US commentators to call for Washington to take a tougher stance towards Kabul.

The Afghan leader in past weeks has also demanded US special forces leave the flashpoint province of Wardak and banned international troops from university campuses, both due to unproven harassment claims.

Washington was concerned that the handover of Bagram to Afghan forces would allow suspected Taliban and Al-Qaeda detainees to return to the battlefield. But a final agreement was sealed on Saturday and a handover ceremony was held at the jail shortly before Kerry landed in Afghanistan.