Former US General David Petraeus has been sentenced to two years probation and ordered to pay a $100,000 fine for giving state secrets to his lover.

"I now look forward to moving on with the next phase of my life and to continuing to serve our great nation as a private citizen," Petraeus said outside the federal courthouse in Charlotte, North Carolina, following his sentencing.

The once widely celebrated military leader and commander of operations in Afghanistan and Iraq was often hailed as a potential presidential contender. He retired from the military to lead the Central Intelligence Agency. But then his affair with his biographer Paula Broadwell was exposed in 2012 and he resigned in disgrace.

The classified information he shared with Broadwell never became public, and prosecutors agreed to negotiate probation in exchange for Petraeus' guilty plea last month to one misdemeanor federal charge that he "mishandled" classified information. He gave eight personal notebooks containing secret intelligence to Broadwell, who wrote his biography "All in: The Education of General David Petraeus" in 2012.

The notebooks included information from national security meetings, the identities of covert officers and code words for secret projects.

Prosecutors recommended a $40,000 fine, but Judge David Kessler upped it to $100,000 to "reflect the seriousness" of the crime, he noted in court. "Make no mistake: This is a serious matter," said Kessler, adding that Petraeus' actions "stood in stark contrast to the 37 years of achievement and his remarkable public service".

David Petraeus
Happier times: David Petraeus and Paula Broadwell Getty

The retired general apologised to "those closest to me and others including this court for the pain my actions have caused".

The deal angered FBI agents who worked on the case. They believed he should have faced a stiffer penalty because of the sensitivity of the information and because he initial lied about what he had done, the Washington Post reported.

The FBI began investigating Petraeus after Broadwell sent threatening emails to Jill Kelley, a Florida woman who knew the general. Kelley, unaware of Broadwell's identity, called the FBI. The bureau traced the messages to Broadwell and Petraeus, and discovered that inteligence had been leaked to Broadwell.

It's not clear yet whether Broadwell will be charged.

Petraeus began to cautiously re-emerge into public life in 2013 with the support of his wife, Holly, and friends to take positions at universities and the private equity firm Kohlberg Kravis Roberts.