WASHINGTON — James E. Cartwright, a retired Marine Corps general who as vice chairman of the Joint Chiefs of Staff served as a key member of President Obama’s national security team, agreed to plead guilty on Monday to lying to the F.B.I. about his discussions with reporters about Iran’s nuclear program.

General Cartwright entered the guilty plea before Judge Richard J. Leon of Federal District Court for the District of Columbia. As part of the deal, prosecutors and defense lawyers agreed that under sentencing guidelines, the punishment could range from a $500 fine to six months in prison. However, the government reserved the right to argue for a higher sentence, and the judge is not bound by the guidelines. Judge Leon set a sentencing hearing for Jan. 17.

During the half-hour hearing, General Cartwright spoke stoically and in a calm voice, answering “Yes, sir” to a series of questions posed by the judge to make sure he understood what he was doing.

He did not speak to reporters afterward, but in a statement said that he was not the original source of the information.

“It was wrong for me to mislead the F.B.I. on Nov. 2, 2012, and I accept full responsibility for this,” General Cartwright said. “I knew I was not the source of the story and I didn’t want to be blamed for the leak. My only goal in talking to the reporters was to protect American interests and lives; I love my country and continue to this day to do everything I can to defend it.”

His lawyer, Gregory B. Craig, said in a statement that his client had spoken to journalists after they had already reported their stories and that his motive was to prevent publication of information that might have harmed national security. The investigation focused on leaks to reporters for The New York Times and Newsweek.

For General Cartwright, who was known as “Obama’s favorite general” before his retirement in 2011, the plea amounts to a stunning fall. It also adds a new twist to a surge of leak-related criminal cases in the Obama era.

The case grew out of a period of political furor over leaks in the summer of 2012, when numerous books and articles appeared about Mr. Obama’s national security record during his first term.

Republicans in Congress accused the White House of deliberately leaking government secrets, endangering national security to make Mr. Obama look tough in an election year.

The administration denied that charge, and the attorney general at the time, Eric H. Holder Jr., appointed two United States attorneys to look into two specific disclosures, one of which was the cyberattack on Iran’s nuclear program.

NBC News reported in 2013 that the Iran cyberattack investigation was focused on General Cartwright.

The cyberattack was Operation Olympic Games, a joint United States-Israeli effort to sabotage Iranian nuclear centrifuges with a computer virus sometimes called Stuxnet. A description of it was contained in “Confront and Conceal,” a book by David E. Sanger, a New York Times reporter, that was also adapted as an article published by The Times.

“In researching his book ‘Confront and Conceal’ and his stories for The New York Times, David E. Sanger relied on multiple sources in Washington, Europe, the Middle East and elsewhere. Most of them spoke on the condition of anonymity,” The Times said in a statement on Monday.

“As in the past, neither The Times nor Mr. Sanger will discuss whether a particular person was a source or the sourcing of particular information that was published, beyond what has been disclosed in our stories and in the book,” the statement continued. “Reporting like this serves a vital public interest: explaining how the United States is using a powerful new technology against its adversaries and the concern that it raises about how similar weapons can be used against the U.S. We will continue to pursue that reporting vigorously.

“We are disappointed that the Justice Department has gone forward with the leak investigation that led to today’s guilty plea by General Cartwright,” it added. “These investigations send a chilling message to all government employees that they should not speak to reporters. The inevitable result is that the American public is deprived of information that it needs to know.”

Prosecutors also accused General Cartwright of lying about his conversations with another reporter, Daniel Klaidman, then of Newsweek. They said that the general had falsely told investigators that he had never discussed an unnamed country with Mr. Klaidman, but that he had sent an email to that reporter that “confirmed certain classified information relating” to that country in February 2012.

Mr. Klaidman wrote an article in February 2012 about the Obama administration’s policy toward disrupting the Iranian nuclear program, including a section about a conversation between General Cartwright and Mr. Obama in early 2009 about various covert sabotage efforts. The list included cyberwarfare programs to damage centrifuges. He declined to comment on Monday.

It was reported by Foreign Policy in the fall of 2013 that General Cartwright had been stripped of his security clearance. But with no official word from the Justice Department since then, it had seemed that the case was being handled administratively rather than criminally.

On Monday morning, however, federal prosecutors filed criminal information against General Cartwright stating that on Nov. 2, 2012, investigators showed him “a list of quotes and quotations from David Sanger’s book, a number of which contained classified information,” but that he falsely told investigators that “he was not the source of any of the quotes and statements” and that “he did not provide or confirm classified information to David Sanger.”

General Cartwright’s guilty plea — not for leaking, but for lying to agents pursuing an investigation into an apparent leak — was reminiscent of the case prosecutors brought during the George W. Bush administration against I. Lewis Libby, a former chief of staff to Vice President Dick Cheney. Mr. Libby was charged with lying about his conversations with journalists to investigators looking into the disclosure of a C.I.A. official’s identity, but was not charged over the leak itself.

Before General Cartwright’s plea, the Obama administration had already brought criminal charges in more than twice as many cases involving leaks of government secrets to the news media as were brought under all previous presidents combined. They included eight officials it charged under the Espionage Act, although in some cases that charge was dropped.

In a ninth leak-related case in the Obama era, the government struck a deal with David H. Petraeus, a prominent retired general who served as director of the C.I.A. He pleaded guilty to a misdemeanor charge of mishandling classified information related to accusations that he let his biographer read notebooks containing national security secrets, although she did not publish any of them.

Mr. Petraeus also admitted to lying to the F.B.I., but he was not charged with that offense under his plea deal. He paid a fine and was sentenced to two years of probation.

A version of this article appears in print on , on Page A15 of the New York edition with the headline: Former Joint Chiefs General Admits He Lied to F.B.I. in Inquiry Over Leaks. Order Reprints | Today’s Paper | Subscribe