The judge had described the case against Mr Jawad as an "outrage"
A US judge has ordered the release of one of the youngest detainees at the US detention centre in Guantanamo Bay.
US District Court Judge Ellen Huvelle said Mohammed Jawad would be released by late August. If so, he is expected to return home.
But government lawyers say they have not yet decided whether to pursue a criminal case against him.
Mr Jawad has been accused of injuring two US soldiers and their interpreter by throwing a grenade at their vehicle.
He was 12 when he was arrested in Afghanistan in 2002, his lawyer says, but 17 according to the Pentagon. He has been held at the camp for the past six-and-a-half years.
Earlier, Mr Jawad's lawyer, Jonathan Hafetz, told the BBC he was "cautiously optimistic" his client would be set free.
"They've not produced any evidence so far and enough is enough. It's time for Mr Jawad to go home," he said.
Deputy Assistant Attorney General Ian Gershengorn told the court the US was still deciding whether to pursue a criminal case against Mr Jawad.
Daniel Sandford, BBC News, Washington
The strength of Judge Ellen Segal Huvelle's remarks in this hearing should caution anyone against assuming Mohammed Jawad's story sets a precedent.
Just because he is going home next month, it would be foolish to assume that many others will follow immediately.
He is being released because the case against him fell apart at the military commission hearings when his confession under torture was ruled inadmissible, and there was little other evidence.
Though some detainees will follow a similar path to Mohammed Jawad other detainees have a stronger a case to answer, and their release will be more of a political decision than a legal one.
That would mean he could still be returned to the US, or have his repatriation delayed, to stand trial in a criminal court.
Judge Huvelle gave government lawyers three weeks to file the criminal case, but urged them not to do so.
"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."
Mr Hafetz said it would be "another traumatising experience" for Mr Jawad and that the "nightmare will continue for no good reason".
The Afghan government has requested that he be sent home and in October 2008, a US military judge ruled confessions Mr Jawad had made were inadmissible because they were obtained under torture.
In July this year, Judge Huvelle described the US government's case against Mr Jawad as "an outrage" that was "riddled with holes".
Charged in Afghanistan in December 2002 for allegedly attacking a US military jeep
Claims his confession was obtained using torture
US government's case against him described by a judge as "riddled with holes"
Observers say that if Mr Jawad is returned to Afghanistan it could mean that other Guantanamo detainees will also be released.
Shortly after entering the White House, US President Barack Obama pledged to close the prison at Guantanamo Bay.
Since making the pledge, administration officials have been reviewing the case files of Guantanamo detainees in an attempt to determine which prisoners should face criminal trials, which should face military commissions, which should be released and which can neither be tried nor released.
Mr Obama has said he wants the camp to be closed by January 2010.