Despite the national security concerns raised by the disclosure, one official said, the general's downfall reads more like a soap opera than a spy novel. Concerned after discovering correspondence because of an earlier Chinese hack into Google's G-mail service, which the McAfee internet security company dubbed ''Operation Aurora'', the FBI was investigating whether Mr Petraeus' private or CIA email accounts had been compromised, the official said. Three people, all intelligence, military or congressional officials, have identified Broadwell, who wrote All In: The Education of David Petraeus, as the woman who had an affair with him. While the investigators interviewed Mr Petraeus for the first time in late October, the official said, the FBI didn't tell his nominal superior, Director of National Intelligence James Clapper, of its findings until late on election day, November 6, a second US official said. Mr Clapper recognised immediately that Mr Petraeus could not remain at the CIA and informed National Security Adviser Tom Donilon of the matter on November 7.

The first official said there appear to be no criminal or national security matters involved. Often mentioned as a future presidential candidate, Mr Petraeus disclosed the affair and the surrounding investigation in a meeting with Mr Obama on November 8, according to a person familiar with the matter. Mr Obama did not accept his resignation right away, but on Friday, he called Mr Petraeus and accepted it. The affair did not jeopardise Mr Petraeus' high-level security clearances because he already had passed the polygraph exam required for a top secret clearance as a senior military officer and didn't need to retake it at the CIA, the official said. Broadwell's book examining his career and leadership style began as her PhD dissertation.

Like Mr Petraeus, she was a fitness enthusiast and graduate of the US Military Academy at West Point. During more than 15 years of military service, she served with the US intelligence community, Special Operations Command and FBI joint terrorism taskforces. In 2010, Broadwell ''was embedded with the general, his headquarters staff and his soldiers on the front lines of fighting across Afghanistan'', according to her website, www.paulabroadwell.com. In her book's preface and during a January 25 appearance on Comedy Central's The Daily Show, Broadwell said she had interviewed Mr Petraeus while the two went running. ''I thought I'd test him, but he was going to test me,'' Broadwell told host Jon Stewart. ''It ended up being a test for both of us.'' When he didn't want to answer questions, she said, ''he would pick up the pace so neither of us could talk''.

The sudden departure of Mr Petraeus leaves another national security vacancy for Mr Obama to fill, with Secretary of State Hillary Clinton and Defence Secretary Leon Panetta expected to leave some time next year, possibly along with Mr Clapper. Mr Petraeus got mixed reviews from intelligence officers he commanded. While some admired his intellect and political savvy, others regarded him as too enamoured of drone strikes and other military operations, excessively self-assured and not sufficiently interested in rebuilding the CIA's less glamorous human intelligence capabilities. He leaves an agency embroiled in the fallout from the deaths of four US citizens, including the ambassador to Libya, in the September 11 attack on the US diplomatic compound in Benghazi. Loading Mr Petraeus was to testify at the Senate intelligence committee this week. He no longer will appear at the session, a spokesman for the committee said. He also will not appear at a House intelligence committee hearing.

In a November 5 Newsweek article she wrote about Mr Petraeus' rules for living, Broadwell lists as No. 5: ''We all will make mistakes. The key is to recognise them and admit them, to learn from them, and to take off the rear-view mirrors - drive on and avoid making them again.'' BLOOMBERG, AGENCIES