Updated

A federal judge in Virginia sentenced former FBI agent Robert Philip Hanssen to life in prison without chance of parole Friday for being a Moscow spy.

Hanssen traded crucial U.S. secrets for cash and diamonds for more than two decades. His sentencing closes a chapter in one of America's most-damaging spy scandals.

The 58-year-old Hanssen, standing in a green prison uniform before U.S. District Judge Claude Hilton, thanked his family, friends and co-workers who have expressed support. "I am humbled by your generosity, your goodness and your charity," Hanssen said to a hushed, packed courtroom audience that included many of former FBI colleagues.

The sentencing ended the Hanssen courtroom saga. But the effects of what authorities describe as his extraordinary betrayal will resonate for years through the FBI and the U.S. intelligence community. Chastened FBI officials already have broadened the use of lie detectors and financial checks into the backgrounds of agents to try to prevent a recurrence.

"I apologize for my behavior. I am shamed by it," Hanssen told the judge. "I have opened the door for calumny against my totally innocent wife and children. I have hurt so many deeply."

U.S. Attorney Paul McNulty told reporters: "This brings to a close one of the darkest chapters of American history. Robert Hanssen was trained and he was entrusted to guard us. He betrayed us. He turned his back on us."

To those who would consider spying against their country, McNulty said, "Robert Hanssen was trained to catch spies. He was an expert at what it took to avoid being caught, and he was caught and he was punished."

Under a plea agreement that Hanssen and his attorney struck with government, his wife, Bonnie, was permitted to receive the survivor's portion of his FBI pension and keep the family's home in Vienna, Va. She was not present at his sentencing.

As Hanssen was brought into the courtroom around 9 a.m. EDT, he greeted his lawyer, Plato Cacheris, warmly, and scanned the courtroom for faces he recognized. His hair had turned gray and he seemed to have lost weight since he was apprehended over a year ago.

Judge Hilton told Hanssen he believed that life in prison was appropriate under sentencing guidelines and under a plea agreement that Hanssen reached with prosecutors. The sentence will not allow parole or early release.

Before Hanssen was sentenced, Assistant U.S. Attorney Randy Bellows told the judge that Hanssen "broke every major promise he made" and that he "took the nation's most critical secrets ... and used them as personal merchandise. He was in essence the cruelest kind of thief."

Authorities said that over a period of two decades, Moscow paid Hanssen with two Rolex watches and $600,000 in cash and diamonds, and promised that $800,000 more had been deposited in a bank there on his family's behalf. The FBI also recovered $50,000 from the Russians when it arrested Hanssen in February 2001.

Hanssen's spying peaked at the height of the Cold War, and officials said his activities were at least in part responsible for the deaths of at least three spies overseas. They included a Russian Army general code-named "Top Hat" who was one of America's best intelligence sources and who was executed in 1986.

Prosecutor Bellows said the value of secrets that Hanssen compromised made the purchase by the Russians "the bargain of a lifetime."

Cacheris noted that Hanssen had cooperated with investigators since his arrest in February 2001 and has undergone 200 hours of questioning over 75 days. He said Hanssen had waived his priest's privilege and his attorney's privilege and has undergone psychoanalysis.

Cacheris said the sentence of life in prison was appropriate.

Speaking to reporters outside, Hanssen's lawyer was asked to assess the intelligence damage from his client's activities.

"I would leave that, really, for the intelligence community," Cacheris replied.

"Obviously, this is a serious case. Otherwise, the punishment wouldn't have been as extreme as it is," Cacheris said. "There wouldn't have been threats of the death penalty."

The government had filed court papers Monday saying it would stand by its agreement not to seek the death penalty for Hanssen, despite "serious reservations" from the CIA and Justice Department about his cooperation with interrogators.

This came after CIA officials told prosecutors they were displeased with Hanssen's claims that he suffers from a poor memory. And Justice's Office of Inspector General said Hanssen's answers to its investigators often were "contradictory, inconsistent or illogical."

But FBI investigators said they thought Hanssen had sufficiently met the terms of the plea agreement, saying he "provided information during the debriefings that was identical or consistent with independent investigative results, and in some cases was previously unknown to us and damaging to himself."

Cacheris said earlier that Hanssen had been candid and forthright during his interviews.

The Associated Press contributed to this report.