Lined-up in a hot and dusty parade ground in Bagram military base around 200 newly qualified Afghan military police saluted as their national flag was winched up the flag pole.

These men are part of a team of more than 2,000, who are taking over security for Parwan prison from the US military.

The ceremony, peppered with several renditions of the Afghan national anthem, was a deliberate public assertion of Afghan sovereignty.

But, in reality, the Afghans are still not completely in charge here.

The handover was ordered six months ago by Afghan President Hamid Karzai. Back in March tensions were high after American troops had inadvertently burnt copies of the Quran.

The US commander of the prison facility described the job of getting the transition complete as a "monumental task".

Most of the 3,000 prisoners at Parwan are now under Afghan control. But there are about three dozen men the Americans have decided not to handover just yet.

The US wants the Afghans to maintain a system that allows wartime prisoners to be detained without trial. These are men deemed too difficult to prosecute but too dangerous to release.

The US says that this was agreed with the Afghan government in a memorandum of understanding signed in March. But, Afghan politicians haven't ratified this deal, with some believing it is unconstitutional.

The Afghan government maintains it is legal.

So, the US fears that men it deems dangerous could end up being released by the Afghan authorities and then end up back on the battlefield.

Karzai wants to show that his government exercises sovereign control over prisons on its soil. That won't be true until the all the Afghan prisoners are handed over.

But with NATO's forces still engaged in battle over many parts of Afghanistan, they're still going to want to detain and interrogate suspects themselves.

There is also the question of the foreign, mainly Pakistani, inmates held at Bagram. They will also remain under US control.

Follow Bernard Smith on Twitter: @JazeeraBernard