June 23, 2011: Former CIA Director Gen. David Petraeus testifies on Capitol Hill in Washington.

General David Petraeus has pleaded guilty to a misdemeanor charge in connection to his handling of classified material -- striking a plea deal with the government that avoids an embarrassing trial and keeps him out of prison over whether he leaked private information to his mistress when he headed up the CIA.

Instead of jail time, federal prosecutors will ask the judge for two years of probation for Petraeus.

The criminal complaint, filed Tuesday in the United States District Court for the Western District of North Carolina’s Charlotte Division, charges Petraeus with one count of unauthorized removal and retention of classified material.

The plea deal marks a spectacular fall for the retired four-star general, who was once considered a possible presidential or vice presidential candidate  for the United States.

Petraeus’ mistress, Paula Broadwell, a former Army  Reserve officer who had an affair with  Petraeus in 2011, when she interviewed him for a biography she was writing on him titled, “All In: The Education of General David Petraeus.”

Petraeus resigned from his post at the head of the CIA in 2012.