"Colleen LaRose had as much chance of killing Lars Vilks as I did," he said.

After Khalid's arrest, he was diagnosed with Asperger's syndrome and depression. Prosecutors have not contested the diagnosis.

Lindy said the judge should give weight to Khalid's age, his psychological difficulties and his growth in jail. Although Khalid had graduated from high school, he obtained a GED so he could teach the syllabus to other inmates.

"The Asperger's in conjunction with his adolescence created a crucible," Lindy said.

In testimony for the defense, forensic psychologist Steven Samuel said the undiagnosed problems would have caused Khalid to have difficulty relating to people in the world around him and that he would have struggled to comprehend the gravity of his actions.

"People with Asperger's syndrome don't get cause and effect," Samuel said. "They are easily manipulated."

Samuel, who interviewed Khalid, said he withdrew from his family — eating meals alone in his room and at one point starving himself in a bid to convince his family to return to their native Pakistan — and became ever more tightly wrapped up in his online world.

On the Internet, Samuel said, Khalid was easily able to win the admiration of adults for his intelligence.

That intelligence helped Khalid to excel at Mount Hebron and earn a full scholarship to the Johns Hopkins University. But Samuel said his personality was also marked by childishness and naivete.

As Khalid stood up to address the judge, he said he had difficulty expressing himself clearly.

"I'm still learning how to speak," he said.

After the hearing, the lawyers maintained the positions they had taken in front of the judge.

"His conduct had real ramifications in the world of violent jihad," Williams said. "This was a real terrorist cell, these were real people plotting real things."

Outside the courthouse, Lindy took an aggressive tone. In decades to come, he said, people would view the prosecution of people such as Khalid as a disgrace and accused the government of badly mishandling the case.

"When they came to see him that very first time, they should have said, 'Get yourself a lawyer,'" Lindy said. "They didn't do that. They debriefed him eight different times. They ought to be ashamed of themselves."