ALEXANDRIA, Va. (CN) – Nearly a year after a jury found former CIA contractor Kevin Patrick Mallory guilty of conspiring to sell American defense secrets to a Chinese spy, a federal judge sentenced the longtime U.S. intelligence insider to 20 years in prison Friday.

Kevin Mallory, of Leesburg, Virginia, was convicted of espionage for transmitting top-secret documents to Chinese operatives. (Photo via LinkedIn)

Mallory, 62, looked ashen as he walked to a podium before U.S. District Judge T.S. Ellis III to deliver a brief statement before his sentence was handed down.

“My love for our country never wavered. My love for my family is very deep,” he said.

Ellis called Mallory’s crime of espionage “very serious.” The judge said that while Mallory served for years in the U.S. military, spying for a foreign government means he “erased” some of the merit of that service.

“I believed you thought you could walk a fine line,” the judge said, noting Mallory’s decision to simultaneously accept $25,000 from the Chinese for two classified documents while also reporting to the FBI on his correspondence with suspected Chinese intelligence officer Michael Yang.

It was during one of those meetings with the FBI before his arrest that Mallory inadvertently revealed a chat log between himself and Yang.

On the encrypted cellphone – also known as a “covcom,” or covert communication device – the messages made it clear: Mallory offered to send Yang more documents and was willing to use steganography, the process of concealing a document inside of an image, to do it.

It was also clear that he planned on meeting with the Chinese for a third trip, but he never made it. Authorities arrested him in June 2017 before he left for Shanghai.

At the time of his exchanges with Yang, Mallory had $30,000 in credit card debt and was about to lose his home.

“You needed money and you were willing to do anything to get it,” Ellis said Friday.

Assistant U.S. Attorney John Gibbs emphasized this point to the judge.

“At its heart, this was a basic crime. He needed money and the most valuable thing to sell was our nation’s secrets,” the prosecutor said.

In addition to working for the CIA, Mallory, a resident of Leesburg, Virginia, also worked for the Defense Intelligence Agency and the State Department.

As a member of the intelligence community, he took an oath to protect classified secrets until the end of his life, Gibbs said, adding that Mallory had plans to keep the cash rolling in.

“Espionage is not about selling information all at once. He needed to keep a criminal conspiracy going for a long time and for that he deserves a just punishment,” Gibbs said.

Ellis agreed with the prosecutor’s characterization.

“If you play footsie with another country, you have made a decision to commit a crime,” the judge said. “And I want to make it very clear to those in the intelligence community with this sentencing: when you are contacted by someone making a run at you, you say no, you report it and you run. Don’t play footsie, it’s fatal.”

The 20-year sentence is less than the life sentence sought by the government but double the 10 years requested by the defense team.

Mallory’s sentencing was delayed twice due to disputes over the value of information he passed to Yang. The information included a table of contents and a white paper featuring details about science and technology targeting in China.

Prosecutors argued Mallory intended to continue sending classified documents that would have eventually led him to expose human assets: a husband and wife identified in court documents as “the Johnsons.”

During Friday’s hearing, Gibbs characterized Mallory as the Johnsons’ handler, making his crime a “tremendous betrayal,” he said.

Federal public defender Geremy Kamens painted a less nefarious picture of Mallory’s activities. He said Mallory only accepted a “modest” sum from the Chinese because the information wasn’t that valuable.

But the table of contents wasn’t nearly as innocuous as defense attorneys made it sound, Gibbs argued. It was more of a “laundry list” of what Mallory thought he could provide going forward.

Much of the evidence involved remained under seal during trial and a portion of Friday’s hearing was also classified.

Kamens said Friday they plan to appeal the conviction in two weeks.