Gen. David Petraeus will reportedly plead guilty to providing classified information to his mistress while he was director of the CIA. The plea deal will let him avoid an embarrassing trial and keep his affair out of the limelight.

Justice Department spokesman Marc Raimondi said that Petraeus signed an agreement pleading guilty to one count of unauthorized removal and retention of classified material, the New York Times said Tuesday. The offense carries a maximum penalty of one year in prison.

Petraeus, a four-star general who led wars in Iraq and Afghanistan, was involved in an affair in 2011 with Paula Broadwell, a former Army Reserve officer. Their relationship began when she was interviewing him for a biography, “All In: The Education of General Petraeus.” Petraeus, who was director of the CIA at the time, resigned in 2012 after the FBI started investigating the affair. He had acknowledged the affair but denied leaking any classified information to Broadwell at the time.

The FBI discovered the affair when Jill Kelley, Petraeus’ friend, filed a cyberstalking complaint against an anonymous perpetrator, warning her to stay away from Petraeus.  “It didn’t start with Petraeus, but in the course of the investigation they stumbled across him,” said a congressional official briefed on the matter, according to the Times. The FBI eventually traced the emails back to Broadwell and found evidence of Petraeus sharing classified information with her. President Barack Obama spoke up in defense of Petraeus at the time the allegations were brought against him.

Petraeus, who is still married to his wife Holly, ventured into private equity as a partner in Kohlberg Kravis Roberts and taught at Harvard, the University of Southern California and the City University of New York after his retirement from civil service.