Former CIA Director David Petraeus, whose career was destroyed by an extramarital affair with his biographer, was sentenced Thursday to two years’ probation and fined $100,000 for giving her classified material while she was working on the book.

The sentencing came two months after he agreed to plead guilty to a federal misdemeanor count of unauthorized removal and retention of classified material.

The plea agreement carried a possible sentence of up to a year in prison. In court papers, prosecutors recommended two years’ probation and a $40,000 fine. But Judge David Kessler increased the fine to “reflect seriousness of the offense.” He said Petraeus committed a “grave and uncharacteristic error in judgment.”

Appearing calm and wearing a business suit, Petraeus made a brief statement before he was sentenced, apologizing “for the pain my actions have caused.”

Petraeus attorney Jake Sussman said the case was not about the public dissemination of classified information, but the wrongful removal of materials.

But prosecutor James Melindres said, “This is a serious criminal offense. He was entrusted with the nation’s most classified secrets. The defendant betrayed that trust.”

In a brief statement after the hearing, Petraeus said his sentecning marked the end of a 2 1/2-year ordeal.

“I now look forward to moving on to the next phase of my life,” he said, before walking to a waiting car.

The agreement was filed in federal court in Charlotte, where Paula Broadwell, the general’s biographer and former lover, lives with her husband and children.

The affair ruined the reputation of the retired four-star Army general who led U.S. forces in Iraq and Afghanistan.

Prosecutors said that while Broadwell was writing her book in 2011, Petraeus gave her eight binders of classified material he had improperly kept from his time as the top military commander in Afghanistan. Days later, he took the binders back to his house.

Among the secret information contained in the “black books” were the names of covert operatives, the coalition war strategy and notes about Petraeus’ discussions with President Barack Obama and the National Security Council, prosecutors said.

Those binders were later seized by the FBI in an April 2013 search of Petraeus’ Arlington, Va., home, where he had kept them in the unlocked drawer of a desk in a ground-floor study.

Prosecutors said that after resigning from the CIA in November 2012, Petraeus signed a form falsely attesting he had no classified material. He also lied to FBI agents by denying he supplied the information to Broadwell, according to court documents.

Petraeus admitted having an affair with Broadwell when he resigned as CIA director. Both have publicly apologized and said their romantic relationship began only after he had retired from the military.

Broadwell’s admiring biography of him, “All In: The Education of David Petraeus,” came out in 2012, before the affair was exposed.