Attorney Jeffrey M. Lindy talks to reporters in Philadelphia after his client Mohammad Khalid was sentenced to five years in prison for conspiring to aid terrorists. (Ian Duncan/Baltimore Sun video)

Lawyers argued for almost two hours Thursday whether the skinny, hollow-cheeked young man from Ellicott City sitting in court was a dangerous al-Qaida plotter or a kid with undiagnosed psychological problems who was led astray by a cabal of bumbling terrorist wannabes.

The hard-fought sentencing hearing at U.S. District Court in Philadelphia was the final act in the case of Mohammad Hassan Khalid, 20, who was charged with terror offenses while still a teenager. Khalid's lawyers wanted him released immediately, while federal prosecutors sought to send him to prison for eight years.

In the end, U.S. District Judge Petrese B. Tucker split the difference, handing the former Mount Hebron High School honors student a five-year term with credit for the nearly three years he has already spent in custody. A citizen of Pakistan, Khalid faces deportation when he is released.

Impassioned arguments from lawyers on both sides and tearful words of regret from the young defendant brought to a close a case that attracted particular attention because of the defendant's youth.

"All of my life, whatever is left of it, was wasted in a few years," Khalid said, as his family sat feet away in the windowless, wood-paneled courtroom.

In the online world he inhabited, Khalid said, he had found a "force of hate so strong that it trapped me in its claws."

Prosecutors and Khalid's lawyers offered the judge sharply different interpretations of his actions and their motivations.

Prosecutors said Khalid collaborated with dangerous terrorists who hatched a plot to kill Swedish cartoonist Lars Vilks, whose illustrations of the Muslim prophet Mohammad had angered them.

Khalid's lawyers portrayed the terror cell as a hapless crew of aspirants, and its youngest member as a teenager with Asperger's syndrome who was seeking validation from adults.

Khalid pleaded guilty in May 2012 to conspiracy to provide material assistance to terrorists for his contributions to the scheme, which included sending a package overseas that contained identity documents to be used by his co-conspirators.

The group included another suburbanite, the Pennsylvania woman known as Jihad Jane, who traveled to Europe in an attempt to carry out the killing, and allegedly Ali Charaf Damache, an Algerian living in Ireland.

Prosecutors say Khalid believed he would be part of an elite terror team with them.

In January, the judge sentenced Colleen LaRose, known online as Jihad Jane, to a 10-year prison term. Damache is in Ireland battling extradition.

Prosecutors also said Khalid's communication with the others and mailing the package captured only a part of his role. Just as important to terrorist groups, they said, was his prowess at translating propaganda into English.

"They need people like Mohammad Khalid to make the doctrine accessible," said assistant U.S. attorney Jennifer Williams. "He had a real brilliance and charisma in the way that he did it."

As the case mounted against LaRose, Williams said, the FBI visited Khalid at his family home on several occasions and warned him to give up his online activities.

But instead, she said, he wore his status as a marked man with pride and continued his efforts.

Khalid was arrested in secret in 2011 and began to cooperate with federal investigators on several terrorism cases.

Williams said his deep ties to the world of online jihadi propaganda made him a valuable source for the government, and prosecutors made a motion for him to receive a lighter-than-usual sentence as a reward for his aid.

Jeffrey M. Lindy, one of Khalid's lawyers, urged the judge not to lose sight of his view that the plot was "half-baked" and never stood a chance of success.