WASHINGTON — The plea deal given to retired Gen. David H. Petraeus, which spares him prison time even though he gave military secrets to his mistress, reveals a “profound double standard” in the way the Obama administration treats people who leak classified information, a lawyer for an imprisoned government contractor wrote in a letter to prosecutors.

The sharply worded letter calls for the Justice Department to immediately release from prison Stephen J. Kim, an arms expert and former State Department contractor who is serving a 13-month sentence for disclosing classified information about North Korea to Fox News. Mr. Kim has said he was trying to call public attention to the threat posed by that country.

Mr. Petraeus, one of the most celebrated American generals of his generation, is scheduled to be sentenced next month for giving his handwritten journals — containing notes from his meetings with the president, the names of covert officers and other secrets — to his lover for a glowing biography she was writing about him. The Justice Department agreed not to seek jail time.

“The decision to permit General Petraeus to plead guilty to a misdemeanor demonstrates more clearly than ever the profound double standard that applies when prosecuting so-called ‘leakers’ and those accused of disclosing classified information for their own purposes,” wrote Abbe D. Lowell, a lawyer for Mr. Kim.