John Walker Lindh, the suburban Californian whose actions on the battlefields of Afghanistan evoked passions across this country, was sentenced to 20 years in prison yesterday, after he tearfully apologized for signing on as a foot soldier for the Taliban.

"I did not go to fight against America, and I never did," Lindh told U.S. District Judge T.S. Ellis III in Alexandria. "I have never supported terrorism in any form, and I never will. . . . I made a mistake by joining the Taliban. Had I realized then what I know now, I would never have joined them."

Lindh, 21, pleaded guilty in July to one count of providing services to the Taliban and one count of carrying explosives during a felony. The government and the defense agreed that a 20-year sentence was appropriate, and Ellis spoke at length in defending his decision to accept the plea bargain.

He did so as the father and wife of slain CIA officer Johnny "Mike" Spann sat in the courtroom, openly displeased with the sentence. Spann was killed in an uprising at the same Afghan fort where Lindh was being held in November, and Spann's father told Ellis he believed Lindh played a role in his son's death.

"Our government did not have evidence which linked this defendant to the murder of Mr. Spann," Ellis said. "Had they had that evidence, I would not have accepted the plea."

Lindh's apology lasted 20 minutes, and he did not mention Spann until asked explicitly about him. He spoke haltingly, taking time to compose himself several times, expressing remorse and condemning terrorism. He converted to Islam as a teenager in Marin County, Calif., and had studied Arabic in Yemen and Pakistan before venturing to Afghanistan.

"I went to Afghanistan because I believed it was my religious duty to assist my fellow Muslims militarily in their jihad against the Northern Alliance," he said. "In Islamic terminology, jihad refers to the spending of one's utmost exertion in the service of God. I have never understood jihad to mean anti-Americanism or terrorism."

Lindh said he had read reports of atrocities committed by Northern Alliance troops and said those same forces had fought alongside the Soviet Union during the Soviets' 10-year occupation of Afghanistan. "I saw the war between the Taliban and the Northern Alliance as a continuation of the war between the mujahideen and the Soviets," Lindh said.

Lindh's attorneys noted in a pre-sentencing brief that Lindh never fired his weapon while in Afghanistan. He reached the front line Sept. 6, 2001, served as a guard and then was in retreat once the U.S. bombing began in November.

Johnny Spann, the slain CIA officer's father, was skeptical of that claim, telling the judge: "Are we supposed to believe that any kind of army would let somebody be on the front line and never fire his weapon? That's a little hard for me to believe."

Standing at the courtroom podium, Spann looked down at Lindh several feet away and said, "I'm very familiar with crying." He said that exactly one year ago, Mike Spann had to explain to his two young daughters that he was leaving for Afghanistan. He also said the task fell to him to tell the girls that their father would not return.

Spann said he believed that his son was executed inside a house at the Qala i-Janghi fort, rather than in the courtyard, and that Lindh was in the house, too. "I think he knows more than what he's saying about Mike," Spann said. "I feel like it's not a just punishment."

Ellis said that even if Lindh was in the same house as Spann, "it doesn't show that he did it. Proximity is not guilt."

When Ellis later asked him about it, Lindh flatly said, "I had no role in the death of Johnny Michael Spann."

The judge seemed acutely aware of the opinion some have expressed that a 20-year sentence for Lindh wasn't enough. He spent an hour explaining the legal process and said he was surprised when the lawyers presented the plea bargain to him an hour before a July hearing.

"I asked if there was evidence of involvement in the murder of Mr. Spann," the judge said. "The government said no. I thought that it was a plea that was within the range of reasonableness. I think it is basically a fair result."

As part of the plea bargain, the government dropped more serious charges that would have resulted in a life sentence, including conspiring to kill Americans abroad. Although there is no parole in the federal system, prisoners may earn up to 15 percent reductions in their sentences for good behavior, meaning Lindh could be released in 17 years.

Part of Lindh's agreement requires him to cooperate with government investigators, and U.S. Attorney Paul J. McNulty said after the hearing that Lindh's debriefings had been productive so far. He declined to elaborate.

Lindh said that his time in Afghanistan was limited to military life as a trainee and soldier. He said he had not known of the Taliban's repressive ways, particularly with women, or of its relationship with Osama bin Laden.

"Bin Laden's terrorist attacks are completely against Islam," Lindh said, "completely contrary to the conventions of jihad and without any justification whatsoever. . . . Terrorism is never justified and has proved extremely damaging to Muslims around the world."

Lindh's parents, older brother and younger sister sat in the second row behind him, and they wept as he made his remarks. When the hearing ended, they huddled together in prayer in the courtroom, then left without making any statements.

Ellis agreed to a defense request to recommend that Lindh be imprisoned near his family in California. The federal Bureau of Prisons is not bound by that recommendation.

The lead defense lawyer, James J. Brosnahan, said that Lindh wrote his statement himself, and that "it came from the heart. He has no quarrel with the American people. . . . He wanted to be heard, and he wanted the American people to hear him."

U.S. Attorney Paul J. McNulty, second from left, said John Walker Lindh's debriefings, which are part of the plea agreement, have been productive.John Walker Lindh pleaded guilty in July in Alexandria.