Describing his behaviour as "unacceptable" for the leader of the nation's main intelligence agency, Petraeus, in a statement, said he had submitted his resignation to US President Barack Obama, and that he had shown "extremely poor judgement".
Petraeus said: "After being married for over 37 years, I showed extremely poor judgment by engaging in an extra-marital affair.
"Such behaviour is unacceptable, both as a husband and as the leader of an organisation such as ours. This afternoon, the president graciously accepted my resignation."
Petraeus turned CIA boss in 2011 after heading international forces in Iraq, then in Afghanistan.
He was the highest-profile military officer of the post-9/11 years and was admired for his role running the "surge" in Iraq and implementing a counter-insurgency strategy in Afghanistan.
Petraeus' resignation came just three days after President Barack Obama's re-election, and prompted a flurry of statements from the White House, intelligence community and Petraeus himself.
Announcing his decision to step down, the former general was full of contrition.
CIA deputy director Michael Morell will serve as acting director of the agency, the White House confirmed.
In a statement, President Obama said : "David Petraeus has provided extraordinary service to the United States for decades.
"By any measure, he was one of the outstanding General officers of his generation, helping our military adapt to new challenges, and leading our men and women in uniform through a remarkable period of service in Iraq and Afghanistan, where he helped our nation put those wars on a path to a responsible end.
"As Director of the Central Intelligence Agency, he has continued to serve with characteristic intellectual rigor, dedication, and patriotism. By any measure, through his lifetime of service David Petraeus has made our country safer and stronger."
From Our Network
- Revealed: This woman is the reason behind Salman Khan and Sanjay Dutt’s cold war
- Down a ‘Patiala Peg’, Virat Kohli, Chris Gayle, and Mandeep Singh show how Bhangra is done
- Arijit Singh speaks up on his tiff with Salman Khan, reveals what exactly happened
- TMC chief Mamata Banerjee to be sworn in as West Bengal CM today
- US asks Pakistan to cooperate with India on 26/11 probe