A former CIA officer has been sentenced to three and a half years in prison for leaking details of a secret mission to thwart Iran’s nuclear ambitions, a sentence that was received with a measure of relief from his legal team and paled in comparison to the decades-long term that had been on the table.

Jeffrey Sterling, 47, had faced federal sentencing guidelines calling for 20 years or more, as well as a push by prosecutors urging a severe sentence for a leak they said hit the nation’s security apparatus at its core.

A jury convicted him in January of telling the New York Times journalist James Risen about a classified plan to trick the Iranian government by slipping flawed nuclear blueprints through a Russian intermediary.

CIA whistleblower Jeffrey Sterling

CIA whistleblower Jeffrey Sterling

The former secretary of state and national security adviser Condoleezza Rice testified at Sterling’s trial that the Merlin mission was one of the few options available to the US as it sought to stop Iran’s nuclear program.

After the sentencing on Monday, defense lawyers Edward MacMahon and Barry Pollack thanked US district judge Leonie Brinkema for what they considered a fair sentence. They said they still plan to appeal against the conviction.

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

Sterling showed no visible reaction when the judge imposed the sentence. He spoke briefly before the sentence was imposed but made no admission of guilt and did not apologize, as is common at sentencing hearings. Instead, he simply thanked the judge and the court staff for treating him courteously.

Prosecutors did not recommend a specific term of imprisonment but made clear that they were seeking a severe sentence. They seemed dissatisfied with Brinkema’s decision. Prosecutor James Trump questioned whether Brinkema really intended to impose a 42-month term that runs concurrently on all nine counts of conviction, because the result is that Sterling is serving the same term that would have been imposed if the jury had convicted him on only a single count.

Brinkema said that was indeed her intention. At the start of the hearing, she told both sides right away that the guidelines’ calculation of 20 years was too high.

The defense said his punishment should be more in line with that of former the CIA director David Petraeus. He got probation last month for leaking classified information to his biographer, who was also his mistress.

Instead, Brinkema compared Sterling to another case that defense lawyers had cited in their papers. John Kiriakou, also a former CIA officer, pleaded guilty in 2012 to disclosing the identity of a covert agent to a reporter and was sentenced to two and a half years in prison. Brinkema said the offenses were similar but that Sterling should get a slightly longer sentence because Kiriakou admitted his guilt in a plea bargain, while Sterling admitted no wrongdoing and went to trial.

CIA whistleblower John Kiriakou

CIA whistleblower John Kiriakou

He said the environment now for whistleblowers is “worse than it’s ever been”, not only because of the prosecutions but because of the pervasiveness and effectiveness of surveillance technology that makes it easy to know who is talking.

The classified operation at the heart of the trial involved using a CIA asset nicknamed Merlin, who had been a Russian nuclear engineer. Merlin traveled to Vienna in 2000 to foist deliberately flawed nuclear-weapons blueprints on the Iranians, hoping they would spend years trying to develop parts that had no hope of ever working.

Risen published details of the Merlin operation in his 2006 book State of War.

Sterling was charged in 2010 but the trial was delayed for years, in part because of legal wrangling about whether Risen could be forced to testify. Ultimately, prosecutors chose not to call Risen as a witness, despite winning legal battles allowing them to do so.

Without Risen’s testimony, prosecutors built a circumstantial case against Sterling. They introduced evidence showing regular contact between Risen and Sterling by phone and email.

Prosecutors argued that Sterling was motivated by spite to retaliate against perceived mistreatment at the agency. Sterling, who is African American, had unsuccessfully sued the agency for racial discrimination.