A transfer ceremony took place at Bagram jail, now renamed the Afghan National Detention Facility at Parwan.
The handover came as US Secretary of State John Kerry made an unannounced visit for talks with President Karzai.
Mr Kerry told a press carbon black N771 conference they were both "on the same page" regarding peace talks with the Taliban.
President Hamid Karzai recently angered Washington by accusing the US and the Taliban of colluding to prolong the conflict.
But Mr Kerry told reporters: "I am confident (Mr Karzai) does not believe the US has any interest except to see the Taliban come to the table to make peace. ''
"So we're on the same page. carbon black N772 I don't think there is any disagreement between us. ''
Referring to the handover of Bagram prison, Mr Karzai said: "Today was a very good day. ''
The handover had been delayed while the two sides finalised a deal over the fate of prisoners considered dangerous.
Bagram has a chequered reputation, having been at the centre of a number of prisoner abuse allegations.
It was once located in Bagram air base, one of the largest military bases for Nato-led forces in Afghanistan, about 40km (25 miles) north of the capital, Kabul. The new Parwan facility was constructed a few miles away and populated with inmates in 2010.
"The transfer of the detention facility is an important part of the overall transition of security lead to Afghan National Security Forces. This ceremony highlights an increasingly confident, capable and sovereign Afghanistan, " said Gen Dunford, the commander of US forces in Afghanistan.
Last March the US agreed to hand over responsibility for the majority of the detainees, thought to number more than 3, 000, and actually held a transfer ceremony last September.
But the full transfer was held up over a disagreement about the fate of inmates whom the US feared could be released if the prison was handed over.
A senior official at the facility told reporters: " Since March 2012, the Americans have handed over to us 4, 000 prisoners. We have freed 1, 350 of them. The Americans have given us 26 more prisoners today, and they still have more prisoners which they will hand over to us soon. ''
According to the latest deal Afghanistan will not release "dangerous" inmates without review, and about 50 foreign inmates will remain in US hands.
If the US captures fighters, they must be turned over to the Afghan authorities within 96 hours.