The US has handed control of the controversial Bagram jail and most of its 3,000 suspected Taliban inmates to Afghan authorities.
The jail complex, which is close to the capital Kabul, has been likened to the Guantanamo Bay detention centre and Abu Ghraib prison in Iraq for its association with lengthy detentions and torture.
The handover has raised fears that prisoners could now be more vulnerable to further rights abuses.
Afghan President Hamid Karzai called this transfer "a victory for Afghan sovereignty" as he officiated at the flag-raising ceremony.
It is a move the Afghan leadership was keen to see ahead of the foreign troops’ withdrawal from the country, which is to be completed by 2014.
The prison, known as Parwan Detention Facility, was built about three years ago to replace a holding facility that had been located in an old Soviet hangar inside the base.
Bagram jail hit the headlines last February when US President Barack Obama wrote a letter of apology to President Karzai after copies of the Koran were accidentally thrown out with rubbish and burned by US troops.
There were violent demonstrations right across the country.
There have also been investigations into claims the US Army abused detainees at Bagram after allegations emerged in 2010 of prisoner abuse at a hidden facility at the base.
Investigators have examined claims that prisoners have been tortured, held without evidence and subjected to humiliating body searches.
Former inmates have told of waterboarding, sleep deprivation and food shortages.
Many prisoners at the jail have been held for years without trial and there is a fear that Afghan authorities will maintain the US policy of detention without trial at Bagram.
The US has delayed the handover of a number of detainees from the main body of 3,000 prisoners.
They have also maintained control of one block of the prison, where any suspected Taliban fighters or terrorists captured in future raids will be held before being handed over.
US Defence Secretary Leon Panetta has spoken to Mr Karzai to discuss obstacles to completing an agreement on the prisoner transfer.
The stand-off has angered the local leadership but now the Afghan flag is flying over the prison.
It marks an important milestone for Mr Karzai’s administration as he tries to prove to the Taliban and the Afghan people that he is not a US puppet.