Former CIA officer Jeffrey Sterling, second from left, leaves the Alexandria courthouse after he was convicted in January. (Kevin Wolf/AP)

A former CIA officer who gave a journalist classified information about an operation to stem Iran’s nuclear ambitions was sentenced Monday to 3   1/2 years in prison — a penalty that is longer than what others in recent leak cases have faced, but not by much.

As she handed down the punishment for Jeffrey Sterling, U.S. District Judge Leonie M. Brinkema said she was moved by all that the 47-year-old had accomplished but that she needed to send a message to others: “If you do knowingly reveal these secrets, there’s going to be a price to be paid.”

She said that Sterling caused particular damage by effectively revealing the identity of a man working with the CIA — saying there was “no more critical secret” than that — and that he deserved a harsher penalty than other recently accused leakers because he had not pleaded guilty and admitted wrongdoing.

Sterling thanked the judge and her staff for their treatment of him during the years-long process and said he was especially grateful that Brinkema changed his trial date so he could attend his brother’s funeral. His attorneys said after the hearing that they were grateful to the judge but still plan to appeal Sterling’s guilt.

“In some cases, the jury gets it wrong,” attorney Barry Pollack said. “That said, the judge today got it right.”

Brinkema allowed Sterling to remain out on bond until federal prison officials determine when and where he should serve his sentence.

Sterling was convicted in January of nine criminal counts for leaking classified information to New York Times reporter James Risen in what prosecutors described as a nefarious plot to embarrass his former employer. Neither prosecutors nor defense attorneys asked for a specific penalty, though they took antithetical views of the case.

Prosecutors asked for a “severe” sentence, arguing that Sterling’s illegal disclosures shut down one of the U.S. government’s few mechanisms to stem Iran’s nuclear program. Assistant U.S. Attorney James Trump argued that one “cannot overstate” the significance of the operation that Sterling effectively ended, and said that Sterling put at risk a Russian scientist who was secretly cooperating with the U.S. government.

“What he did was unconscionable,” Trump said of Sterling.

Defense attorney Edward B. MacMahon Jr. asked Brinkema to consider Sterling’s personal background — noting how he had worked hard to earn his position at the CIA and helped ferret out fraud as a health-care investigator. He said that even if Sterling was as bad as prosecutors characterized him when he was in contact with Risen years ago, he has since changed.

“Whoever he was in 2003,” MacMahon said, “he’s not that person anymore.”

Defense attorneys urged the judge to impose a sentence in line with others who have revealed classified information. They cited Gen. David H. Petraeus, who gave his mistress and biographer access to classified materials and was sentenced to two years of probation and a $100,000 fine; former CIA officer John Kiriakou, who revealed the name of another covert officer and was sentenced to 30 months in prison; and former State Department arms expert Stephen Jin-Woo Kim, who leaked classified information to a Fox News reporter and was sentenced to 13 months in prison.

Federal sentencing guidelines call for a term of 19 years and seven months at the low end and 24 years and five months on the high end, though Brinkema said from the beginning that she thought those figures were “too high.” Defense attorneys argued that such guidelines were intended for spies helping foreign governments. Prosecutors said that Sterling should not be compared to Petraeus, Kiriakou and Kim.

Brinkema said that she was ultimately swayed toward leniency by Sterling’s personal background, but that he should face a more severe penalty than Kiriakou, who, like Petraeus and Kim, pleaded guilty.

“That did not happen in this case,” Brinkema said.

In a written statement, U.S. Attorney Dana Boente said that Sterling’s “attempt to leverage national security information for his own malicious reasons brought him to this sentence today.”

While Sterling’s attorneys praised the sentence, whistleblower advocates who have followed the case were somewhat more critical. Jesselyn Radack, director of national security and human rights at the Government Accountability Project, said that it was the “least worst outcome,” and that any sentence including prison time is “excessive” in light of the deal Petraeus reached.

“This breaks my heart,” she said.

The prosecution of Sterling was notable in its own right, but perhaps even more so because it spawned a First Amendment showdown between the government and Risen. Federal prosecutors initially sought to subpoena the Pulitzer Prize-winning reporter and author, who steadfastly maintained that he would never reveal any of his sources. To the dismay of many in the journalism world, the Justice Department won a victory on that front in the U.S. Court of Appeals for the 4th Circuit, but it eventually backed down and did not call the reporter as a witness at the trial.

An attorney for Risen declined to comment on the sentence.