Former CIA officer Jeffrey Sterling is accused of providing details of a classified program to deter Iran’s nuclear ambitions to a New York Times reporter. (Mark Wilson/Getty Images)

The CIA officers slipped in and out of the courtroom behind the cover of a retractable gray screen and testified using only their first names and last initials. They described clandestine meetings, suitcases full of cash and an obstinate Russian engineer who they hoped would help them derail Iran’s nuclear ambitions.

In a federal courthouse in Alexandria, Va., prosecutors are trying to prove that an ex-CIA officer with an ax to grind gave sensitive national defense information to a reporter. But to make their case — and discourage other would-be leakers — they have to parade his former colleagues and secret sources into semi-open court, and talk about covert methods and missions.

The trial of Jeffrey Sterling, whose fate jurors are set to begin deliberating on Thursday, has offered a daily spectacle worthy of fiction. It has also shown the challenge of prosecuting leakers: To win a conviction, prosecutors have to reveal things the government never wanted out in the open.

Sterling is accused of providing New York Times reporter James Risen details of a classified program to deter Iran’s nuclear ambitions.

Everyone has toed an awkward line to keep information secret that should be under wraps. Even before the trial got underway, attorneys worked in a secure room in the courthouse so that classified files would not find their way into the world. A U.S. marshal in the courtroom makes sure only those with security clearances sit near the edge of the screen that blocks the public’s view of clandestine witnesses.

When a prosecutor asked a Russian engineer about his work for the CIA involving countries other than Iran, he insisted the engineer respond only with “yes” and “no” answers to avoid discussing details. When a former CIA public-affairs director testified about the operation at issue in the case, he assiduously avoided using one agency code name (instead using a substitute others have adopted at the trial). When former secretary of state Condoleezza Rice took the stand, defense attorneys at one point objected that her testimony was pushing beyond the bounds of a protective order.

“When you’re talking about classified information, that complicates everything considerably,” said Barak Cohen, a former federal prosecutor who worked briefly on the Sterling case and now is in private practice at Perkins Coie.

But there still have been public pronouncements that probably make those in the intelligence world uncomfortable. CIA officers have had to read aloud CIA cables and talk of specific “legends” — or fictitious back stories — they used to protect the cover of those working with them. The Russian engineer at the center of the case described how he tried to get faulty nuclear plans into the hands of Iranians at the CIA’s direction and noted that he had undertaken similar efforts involving other countries.

Prosecutors did not ask him to name those countries, and when a defense attorney asked about whether the engineer had heard back from any of them, Assistant U.S. Attorney James Trump interrupted.

“Objection, your honor. That goes beyond the scope of the agreed-upon order,” he said.

The judge ended the line of questioning.

Prosecuting leakers has been something of a hallmark of President Obama’s Justice Department. Over nearly six years, the administration has pursued more such cases than all previous administrations combined. The department is still mulling charges against several high-profile targets, including former CIA director David H. Petraeus, veteran State Department diplomat Robin Raphel and retired Marine Gen. James E. “Hoss” Cartwright.

Sterling’s case might be showing them just how thorny leak cases can get.

The 47-year-old Missouri man, who was fired from the CIA in the early 2000s amid a discrimination lawsuit he filed against the agency, was working as a health-care fraud investigator until he was charged in 2010. He is accused of leaking classified material that helped shape a chapter in Risen’s 2006 book, “State of War.” Until last week, though, Sterling had taken something of a back seat in his own case as prosecutors sparred with Risen in court over whether he could be compelled to testify.

They eventually backed down. Attorney General Eric H. Holder Jr. decreed that Risen could not be asked about his sources, and prosecutors and defense attorneys eventually agreed to let jurors simply hear portions of a transcript of the reporter testifying at a pretrial hearing. Per Holder’s direction, he was never asked then to identify any anonymous sources.

That decision left prosecutors trying to connect Sterling and the journalist without the cooperation of either man and attempting to convince jurors that Sterling was the only person with access to the exact sphere of information that Risen published. And that required a deep dive into Sterling’s and others’ secretive work.

Cohen, the former federal prosecutor, said that even before a case goes to trial, officials must carefully consider whether it is worth charging an alleged leaker. Defense attorneys, he said, have a legal right to all sorts of information that could help them make their case, and prosecutors have no choice but to hand it over.

“They really have to weigh whether they’re serious enough to want to find avenues to provide all this classified information to the defense,” Cohen said.

In the Petraeus case — in which prosecutors have recommended charges, according to reports — Obama has said he has seen no evidence that the material contained sensitive national security information, perhaps distinguishing it from the Sterling case. The Cartwright investigation is a better parallel: The retired general is suspected of revealing classified information about an effort to use a computer virus to sabotage equipment in Iranian nuclear enrichment plants.

The classified material Sterling is accused of leaking is about the Russian engineer, referred to in court only as Merlin, and his work to put faulty nuclear schematics into the hands of Iranian officials. The CIA recruited Merlin after he and his family immigrated to the United States in the mid-1990s.

The way CIA officers told it on the witness stand, Merlin was a know-it-all motivated largely by the money the CIA was paying him. He was supposed to reach out to Iranian officials and pose as a greedy Russian scientist willing to sell his country’s nuclear plans. The plans he was peddling, though, were flawed designs created by U.S. scientists, and if they fell into Iranian hands, they would set the country’s nuclear development down the wrong path.

The operation, of course, is no longer secret. Risen described it extensively in his book and claimed the flaws in the plans were obvious and that the Iranians might have benefited from the U.S. knowledge they contained. But the officers and others were forced to offer even more behind-the-scenes context than Risen did, as prosecutors tried to show that the journalist reported only what Sterling knew.

The officers said there was obvious incompleteness in the plans but also flaws hidden more deeply so Iran would not be able to detect them.

Sterling’s defense attorneys have argued that there is no direct evidence tying their client to any leaks, and they suggested a few other people who might have been sources for Risen.

A spokesman for the U.S. Attorney’s Office and Sterling’s defense attorneys declined to comment for this article.

Prosecutors say Sterling leaked details of the Merlin operation because of an unsuccessful discrimination lawsuit against the CIA. And they allege the harm he caused was real. At their questioning, Merlin’s wife spoke in court of how she was “shocked” after reading Risen’s book and worried that Russia’s intelligence agency could use it to identify her and her husband.

“My family can be in danger,” she said, her English somewhat broken. “My kids can be in danger.”

Asked by a Sterling defense attorney whether she had been approached by Russian intelligence agents, she responded, “No, not yet.”