A U.S. judge has ordered the release of one of the youngest detainees at the Guantanamo Bay military prison in Cuba on Thursday, a move that will likely see him return to his native Afghanistan next month.

U.S. officials wanted to detain Mohammed Jawad at the Guantanamo Bay naval base while conducting an investigation.U.S. officials wanted to detain Mohammed Jawad at the Guantanamo Bay naval base while conducting an investigation. (Brennan Linsley/Associated Press)

Mohammed Jawad is accused of throwing a grenade that injured two U.S. soldiers and their interpreter in Kabul in 2002. The Pentagon contends he was 16 or 17 at the time while defence lawyers say he was 12.

There are no available records of his birth, so it is impossible to independently verify his age.

U.S. District Court Judge Ellen Segal Huvelle ruled he was being held illegally and therefore must be released.

Jawad's defence team has argued that his confession that he attacked U.S. forces was illegal.

While Jawad wasn't tortured by U.S. interrogators, the defence lawyers argue that the confession was obtained by American interrogators soon after he was tortured by Afghan authorities.

Huvelle's ruling, given in a Washington, D.C., courtroom, does not end the case, however. Government lawyers told the judge while the United States is negotiating with Afghanistan for a return next month, they are also pursuing a criminal investigation.

'Horrible, long, tortured history'

Huvelle said she had no authority to prevent an indictment, but she encouraged prosecutors to think hard about problems with the case, including Jawad's mental competency to stand trial and the fact that he's already been incarcerated for 6½ years.

"After this horrible, long, tortured history, I hope the government will succeed in getting him back home," she said.

"Enough has been imposed on this young man to date."

The Justice Department said Friday it would no longer hold Jawad as a wartime prisoner. But officials wanted to keep him at Guantanamo while conducting a criminal investigation, saying the government had new eyewitness evidence and would speed up a grand jury investigation.

Jawad is one of the youngest detainees held at the U.S. military prison at Guantanamo Bay. His case has drawn comparisons to that of Canadian detainee Omar Khadr since both were teenagers at the time of their alleged crimes.

Khadr, who is still being held in Cuba, was 15 when he was detained.

With files from The Associated Press