A Virginia man who worked for the State Department was charged Thursday with espionage, accused of selling classified documents to a person he believed was working for a Chinese intelligence agency.

Kevin Patrick Mallory, of Leesburg, Virginia, appeared in federal court after he was arrested Thursday morning by the FBI.

Federal prosecutor John Gibbs said Mallory could face life in prison. And, if certain conditions are met, Gibbs said, Mallory could even face the death penalty. That seems unlikely, however, because death sentences in espionage cases are rare.

Mallory, 60, was accused of selling three classified documents — one marked Top Secret and the others Secret — to a man he met earlier this year in Shanghai. FBI investigators said Mallory sent a message to his Chinese contact in May that said, "your object is to gain information, and my object is to be paid."

Mallory had a Top Secret security clearance while working for the State Department's Diplomatic Security Service, as well as other federal agencies, and government contractors from 1987 to 2012. Conversant in Mandarin, Mallory has been a self-employed consultant since leaving government service.

According to court documents, Mallory was stopped in April at Chicago's O'Hare airport while returning from a trip to Shanghai. He told a Customs agent that he was not carrying a large amount of cash, but $16,500 was found in his two carry-on bags.

In interviews with the FBI over the following month, court documents say, Mallory revealed that his Chinese contact gave him an electronic device so the two could communicate. Investigators said they found the three classified documents on the device and messages discussing payment.

Mallory requested a court-appointed lawyer and was scheduled to appear in court in a few days for a detention hearing.