ALEXANDRIA, Va. — A former Central Intelligence Agency officer on Monday was sentenced to three and a half years in prison on espionage charges for telling a journalist for The New York Times about a secret operation to disrupt Iran’s nuclear program. The sentence was far less than the Justice Department had wanted.

The former officer, Jeffrey A. Sterling, argued that the Espionage Act, which was passed during World War I, was intended to prosecute spies, not officials who talked to journalists. He asked for the kind of leniency that prosecutors showed to David H. Petraeus, the retired general who last month received probation for providing his highly classified journals to his biographer.

The case revolves around an operation in which a former Russian scientist provided Iran with intentionally flawed nuclear component schematics. Mr. Sterling was convicted in January of disclosing the operation to James Risen, a reporter for The Times, who had revealed it in his 2006 book, “State of War.” Mr. Risen described it as a botched mission that may have inadvertently advanced Iran’s nuclear program.

The Justice Department said that Mr. Sterling’s disclosures compromised an important C.I.A. operation and jeopardized the life of a spy. Under federal sentencing guidelines, he faced more than 20 years in prison, a calculation with which the Justice Department agreed. Prosecutors sought a “severe” sentence.