The charge, unauthorized removal and retention of classified material, stems, in part, from documents the former director allegedly provided to his mistress.
In November 2012, Petraeus resigned as director of the CIA after little more than a year on the job. For 37 years before that, he served in the U.S. Army, including as commander of American forces in Iraq and Afghanistan.
That long and successful career in public service came to an end when a long affair with his biographer, Paula Broadwell, became public.
The plea deal reached with prosecutors includes a recommendation of two years of probation and a $40,000 fine, according to court documents.
Petraeus provided Broadwell access to his “Black Books,” which contained Petraeus' notes, including highly classified material from his command in Afghanistan, according to charging documents in the case.
“A total of eight such books ... contained classified information regarding the identities of covert officers, war strategy, intelligence capabilities and mechanisms, diplomatic discussion, quotes and deliberative discussion from high-level National Security Council meetings, and defendant David Howell Petraeus’s discussions with the president of the United States of America," the documents said.
Petraeus’ attorney, David Kendall told ABC News he had “no comment” on the guilty plea.
Petraeus and Broadwell met while Broadwell was a graduate student at Harvard University working on a dissertation about Petraeus. She ultimately gained tremendous access to the decorated war hero and former four-star general, publishing his biography, “All In,” in January 2012 -- just 10 months before his resignation from the CIA.
Their affair became public by chance. The FBI was trying figure out who had been sending allegedly harassing emails to a Florida woman with ties to senior U.S. military officials.
The FBI traced the emails to Broadwell, and a review of her communications ultimately led the FBI to discover her affair with Petraeus, who was married.
Though Broadwell had a security clearance of her own, the affair raised some national security concerns. Federal authorities wondered whether Petraeus had given her access to information she wasn’t authorized to see, and they wanted to know if she had stored classified material at her home.
Within days of the affair becoming public, FBI agents searched Broadwell’s home in North Carolina.
In recent months, some federal investigators have been pushing more senior officials within the Justice Department to file charges against Petraeus. Eric Holder, however, had yet to sign off on such a move.
In an interview with ABC News’ George Stephanopoulos in January, Holder insisted the Petraeus probe was still “ongoing” and was being “done in a fair and an appropriate way.”
Broadwell was not charged in the case.
Since their affair became public, Petraeus and Broadwell have separately apologized for any pain caused to family, friends and supporters.
In addition, in a private letter to a friend two weeks after his resignation, Petraeus wrote: “I screwed up royally. ... I paid the price, appropriately.”
In 2013, Petraeus joined the global investment firm KKR. He also serves as a visiting professor of public policy at the City University of New York's Macaulay Honors College and serves on several veterans organizations' advisory boards, according to KKR's website.
ABC News’ Jim Avila and Martha Raddatz contributed to this report.