The U.S. officially handed over the only detention facility in the country that has been under the U.S. military control, to the Afghan government in a transfer ceremony Monday.

The ceremony was held at Bagram prison, officially known as the Parwan detention center, located next to the Bagram airbase, the main U.S. military bastion 50 km north of Afghan capital Kabul, news agencies reported.

The transfer had been delayed several times, due to disagreements between the U.S. military and the Afghan authorities over the fate of prisoners.

U.S. Secretary of Defense Chuck Hagel spoke with Afghan President Hamid Karzai over telephone Saturday to finalize the transfer, CNN reported.

"The secretary welcomed President Karzai's commitment that the transfer will be carried out in a way that assures the safety of the Afghan people and coalition forces by keeping dangerous individuals detained in a secure and humane manner in accordance with Afghan law," Pentagon spokesman George Little said in a statement.

The prison, previously known as Bagram Internment Facility, was notorious for torture under former President George W. Bush.

Although conditions have been significantly better under President Barack Obama, there were reports in 2009 and 2010 that the U.S. Defense Intelligence Agency (DIA) ran a classified interrogation facility for high-value detainees inside Bagram Air Field, and prisoners there were sometimes subjected to tougher interrogation methods than those used elsewhere.

Both the New York Times and the BBC reported that prisoners who passed through the facility reported abuse, including beatings and sexual humiliation.

The Afghan president has long registered his disapproval of foreign-run jails that he sees as a serious violation of national sovereignty.

In March last year, the U.S. agreed to hand over responsibility for majority of the detainees, reportedly more than 3,000, and held a transfer ceremony in September.

However, the full transfer was held up over a disagreement regarding the fate of certain inmates, who the U.S. feared, could be released if the prison was handed over.

U.S. forces remained at the prison and continued to guard about 50 foreign inmates not covered by the prison transfer agreement, as well as hundreds of Afghans taken into custody since the initial transfer deal was first signed in March 2012, AFP news agency reported.

Earlier this month, a ceremony transferring the full control to the Afghan authorities was called off after Karzai reportedly rejected part of the deal.

Monday’s transfer will leave the U.K. as the only foreign power still imprisoning Afghans in their own soil.

Dozens of detainees captured by the British military have been held at a Helmand prison, the Guardian newspaper reported. The prisoners are not being tried either under the U.K. or Afghan judicial systems, but the British military is not willing to release men they consider dangerous.