Three weeks later, he gave her the notebooks.

In 2012, the F.B.I. opened a cyberstalking investigation after a friend of Mr. Petraeus’s reported to the authorities that she was receiving threatening messages from someone who appeared to know a lot about Mr. Petraeus’s whereabouts. It was later revealed that the person sending the messages was Ms. Broadwell.

During that investigation, Mr. Petraeus was questioned by F.B.I. agents at the C.I.A. headquarters, where he was serving as director. As part of his plea, Mr. Petraeus admitted that he misled the agents by telling them that he had not given Ms. Broadwell classified information.

Three days after President Obama was re-elected in November 2012, Mr. Petraeus resigned, admitting to the affair but saying he had done nothing illegal.

Mr. Petraeus had been a vocal advocate for the close protection of classified information by government officials. “Oaths do matter,” he said in October 2012 after a C.I.A. officer accepted a plea agreement for disclosing sensitive information, “and there are indeed consequences for those who believe they are above the laws that protect our fellow officers and enable American intelligence agencies to operate with the requisite degree of secrecy.”

The officer later received a 30-month sentence.

Mr. Petraeus’s lawyers have argued that the disclosure of the notebooks to Ms. Broadwell was not as severe as the misdeeds of others whom the Obama administration has prosecuted in a crackdown on leaks, because the information was never made public. But some in the F.B.I. and the Justice Department contended that Mr. Holder’s treatment of Mr. Petraeus represented a double standard, arguing that if he had been a lower-level official, he almost certainly would have gone to prison.

F.B.I. officials were particularly angry over what they viewed as Mr. Holder’s not backing up their agents and allowing Mr. Petraeus to get away with lying to them. For all the high-profile national security, cybercrime and organized crime cases that the bureau leads, its officials believe that its most important function is the ability to gather accurate information from the public.

To protect that function, the Justice Department routinely prosecutes terrorists, politicians, drug dealers and even celebrities. In 2007, the track star Marion Jones was sentenced to six months in prison for making false statements to the federal authorities.