File photo: US General David Petraeus.

Washington -

The director of the Central Intelligence Agency (CIA) resigned from his post, citing an extramarital affair as the reason for stepping down.

The sudden and unexpected departure of David Petraeus, a former four-star general who led the US military's involvement in Iraq and Afghanistan before becoming head of the powerful intelligence agency in 2011, came days after President Barack Obama was re-elected to the White House.

Officials told the Associated Press that the affair was discovered in the course of an FBI investigation. In a separate report, NBC News, citing law enforcement officials, reported that Mr Petraeus' biographer, Paula Broadwell, was the subject of an FBI investigation.

Mrs Broadwell, who is married with two children, co-authored a glowing portrait of Mr Petraeus titled All In: The Education of General David Petraeus, for which she spent a large part of the year in Afghanistan shadowing her subject.

Mr Petraeus, the most decorated soldier of his generation, announced his decision in a letter to the CIA, revealing he had delivered his resignation to the President on Thursday. The woman with whom he had the affair was not named.

“After being married for over 37 years, I showed extremely poor judgement by engaging in an extramarital affair,” he wrote. “Such behaviour is unacceptable, both as a husband and as the leader of an organisation such as ours.”

Mr Obama praised Mr Petraeus's “extraordinary service” to the United States.

The President said Michael Morell, the CIA's deputy director, would serve as acting chief.

Mr Petraeus's resignation comes at a difficult time for the CIA, which has been busy fending off criticism for its handling of an attack on a US consulate in Benghazi, Libya, on 11 September. The attack led to the death of US Ambassador Christopher Stevens and three other Americans.

The US State Department and the CIA have since offered different accounts of the event. Mr Petraeus was scheduled to testify on the matter at a closed hearing before the House Intelligence Committee hearing next week.

While it is not clear whether Mr Petraeus will now attend that hearing, yesterday's revelations have brought to an abrupt end the career of one of the US military's best-known and most respected figures.

As Commander of the International Security Assistance Force in Iraq, the then General Petraeus was widely credited for the “surge” of more than 20,000 soldiers there that helped improve security during the last years of the George W Bush administration.

Following his success there he was placed in charge of the US war effort in Afghanistan. There too, he led an increase pf American troops into the country in an effort to bring about stability, but was unable to repeat his success.

Last year, Mr Petreaus was persuaded by Mr Obama to leave the Army after 37 years and take charge of the CIA. He took up the role in September 2011. - The Independent