An ex-CIA officer was sentenced Friday to 20 years in prison for revealing military secrets to China and potentially seeking to expose human assets who were once his responsibility.

Kevin Mallory, 62, was found guilty back in June on charges of spying for China. U.S. District Judge T.S. Ellis III handed down the sentence which is less than the life sentence as sought by prosecutors but double what the defense requested.

The former intelligence officer was convicted under the Espionage Act for providing classified information to Chinese handlers in exchange for $25,000.

TRIAL BEGINS FOR EX-CIA MAN ACCUSED OF SPYING FOR CHINA

Mallory’s acts first became known to U.S. authorities after he was randomly picked for a secondary screening at Chicago 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.

During voluntary interviews with law enforcement officials, Mallory then was caught off guard when a Samsung phone provided to him by the Chinese showed text conversations between Mallory and the Chinese recruiter.

“Your object is to gain information, and my object is to be paid.” — Kevin Mallory's text to his Chinese handler

“Your object is to gain information, and my object is to be paid,” Mallory wrote in one text message to his Chinese handler.

Prosecutor John Gibbs said that the former CIA officer was “desperate for money, and the most valuable thing he had was our nation’s secrets.” The $25,000 Mallory received was just a glimpse into what would have occurred if he hadn’t been caught, Gibbs added.

FORMER CIA OFFICIAL: 'ABSOLUTELY NECESSARY TO TALK ABOUT' TAKING PREVENTATIVE ACTION AMID IRAN TENSIONS

The 20-year sentence comes after multiple delays, with the judge seeking to clarify the exact value of the information Mallory provided to the Chinese, while the prosecutors and the defense clashed on the issue of whether the defendant tried to put human assets at risk.

While a significant portion of the case remains classified, according to court records, prosecutors believe Mallory either sent or intended to send evidence that would have exposed human assets described as “the Johnsons.” Gibbs said Mallory was the Johnsons’ handler when he was at the CIA.

Judge Ellis ruled that he couldn’t conclusively say that Mallory planned on exposing human assets, but said his “long-term intentions” were sinister.

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

“If you choose to play footsie with another country ... you have committed a crime. Don’t think that you can be a double agent.” — U.S. District Judge T.S. Ellis III

The defense argued that a long sentence shouldn’t be applied, pointing to the small sum of money he received from the Chinese and that he voluntarily disclosed his contacts with the Chinese to his former employers at the CIA.

CLICK TO GET THE FOX NEWS APP

But the judge noted that the reason Mallory received arguably a small figure was because he was caught in an early stage of his work with the Chinese.

Mallory’s attorneys say they will seek to appeal the conviction.