A former CIA officer was sentenced Friday to 20 years in prison on charges that he spied for China and allegations he sought to expose human assets who were once his responsibility.

The sentence issued by U.S. District Judge T.S. Ellis III in federal court in Alexandria for Kevin Mallory, 62, of Leesburg, Virginia, is less than the life sentence sought by prosecutors but more than the 10-year term requested by the defense.

A jury convicted Mallory last year under the Espionage Act for providing classified information to Chinese handlers in exchange for $25,000. Mallory’s scheme began to unravel when he was selected for secondary screening at Chicago’s O’Hare International Airport in April 2017 on a flight back from Shanghai with his son and customs agents found $16,500 in unreported cash.

Later, in voluntary interviews with authorities, Mallory was caught off guard when a Samsung phone given to him by the Chinese displayed text conversations between Mallory and the Chinese recruiter – Mallory had expected the phone’s secure messaging features would keep the conversation hidden.

In one text message, Mallory wrote “your object is to gain information, and my object is to be paid.”

“At its heart, this was a very basic crime,” prosecutor John Gibbs said during Friday’s hearing. “He was desperate for money, and the most valuable thing he had was our nation’s secrets.”

Gibbs said the $25,000 Mallory received was just the beginning of what would have occurred if he hadn’t been caught.

Mallory’s sentence was delayed multiple times as the judge sought clarity on a key point – the value of the information provided by Mallory. In particular, prosecutors and defense attorneys differed sharply on whether Mallory ever intended to put human assets at risk.

Much of the evidence in the case remains classified and even a portion of Friday’s sentencing hearing was closed to the public. But at the bottom of it, prosecutors believe Mallory either sent or intended to send evidence that would have led to exposure of human assets described in court as “the Johnsons.” Gibbs said Mallory was the Johnsons’ handler when he worked at the CIA.

Defense lawyers say Mallory never intended to send it and pointed to computer forensic evidence supporting their claim.

Judge Ellis ultimately ruled that he couldn’t determine conclusively that Mallory intended to send the information though he suspected Mallory’s “long-term intentions” were sinister.

“If I had concluded that sources had been compromised … I would impose a far more severe sentence,” Ellis said.

Defense lawyers pointed to the relatively small amount of money Mallory received, and the fact that he voluntarily disclosed his contacts with the Chinese to his former employers at the CIA.

But Ellis said the amount of money was small only because Mallory was caught at an early stage in his relationship with the Chinese. He said Mallory’s contacts with the CIA suggest an effort to cover his espionage with the Chinese with a veneer of legitimacy by portraying himself as some sort of double agent.

“If you choose to play footsie with another country … you have committed a crime,” Ellis said. “Don’t think that you can be a double agent.”

Mallory’s lawyers say they plan to appeal the conviction.