Some more information (wiki). It seems the US fucked up the whole process, and had to make a plea bargain to avoid having the whole confession thrown out (since they tortured it out of him).
On February 5, 2002, Walker was indicted by a federal grand jury on ten charges, including conspiring to support terrorist organizations and conspiring to murder Americans. The charges carried three life terms and 90 additional years in prison. On February 13, 2002, he pleaded "not guilty" to all ten charges.
Complicating the prosecution was the nature of the confession. Photos emerged from Lindh's captivity of him being held naked and bound, wearing an obscenity-covered blindfold. When details of the conditions of his captivity began to emerge, it was discovered that he had initially been wounded and hidden for a week with limited food, water, and minimal sleep in conditions of freezing water before being captured. After being captured and taken to a room with the only window blocked off, Lindh had his clothes cut off him and was duct-taped to a stretcher and placed in a metal shipping container for transportation. Lindh was not even released from the stretcher when he needed to urinate. Instead, guards propped him upright. When interrogated, he was denied a lawyer despite several requests, and was threatened with denial of medical aid if he didn't cooperate. It took more than a week for his wound to be treated and the bullet removed.
The court scheduled an evidence suppression hearing, at which Walker would be able to testify about the details of the torture to which he was subjected. The government faced the problem that a key piece of evidence???Walker's confession???might be excluded from evidence as having been forced under duress. Furthermore, the hearing would turn a spotlight on the way that U.S. soldiers had conducted the interrogation.
To forestall this possibility, Michael Chertoff, the head of the criminal division of the Justice Department, directed the prosecutors to offer Walker a plea bargain: He would plead guilty to two charges ??? serving in the Taliban army and carrying weapons. He would also have to consent to a gag order that would prevent him from making any public statements on the matter for the duration of his twenty-year sentence, and he would have to drop claims that he had been mistreated or tortured by U.S. military personnel in Afghanistan and aboard two military ships during December 2001 and January 2002. In return, all the other charges would be dropped.
Walker accepted this offer. On July 15, 2002, he entered his plea of guilty to the two remaining charges. The judge asked Walker to say, in his own words, what he was admitting to. "I plead guilty," he said. "I provided my services as a soldier to the Taliban last year from about August to December. In the course of doing so, I carried a rifle and two grenades. I did so knowingly and willingly knowing that it was illegal." On October 4, 2002, Judge T.S. Ellis formally imposed the sentence: 20 years without parole.