In a letter to colleagues Friday, Petraeus said he "showed extremely poor judgment by engaging in an extramarital affair. Such behavior is unacceptable, both as a husband and as the leader of an organization such as ours."
NBC News reported Friday the FBI is investigating whether Paula Broadwell, Petraeus' biographer and the co-author of the book, "All In: The Education of General David Petraeus," had improper access to Petraeus' email. The report said investigators are looking into whether Broadwell had access to classified information.
The online magazine Slate said Friday Broadwell is the woman with whom Petraeus was having an affair. Slate said Obama agonized for 24 hours over Petraeus' resignation before accepting it.
Broadwell is a graduate of the U.S. Military Academy who was embedded in Afghanistan, where she observed Petraeus for a project on leadership and organization.
Petraeus said he asked Obama at a White House meeting Thursday "to be allowed, for personal reasons, to resign from my position as D/CIA."
"This afternoon, the president graciously accepted my resignation," Petraeus said Friday.
"David Petraeus has provided extraordinary service to the United States for decades," Obama said in a statement issued by the White House. "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," the president said.
Obama said he was confident the CIA "will continue to thrive and carry out its essential mission, and I have the utmost confidence in acting Director Michael Morell and the men and women of the CIA who work every day to keep our nation safe."
Obama said his "thoughts and prayers are with Dave and Holly Petraeus, who has done so much to help military families through her own work."
The couple married in 1974.
Petraeus, a retired U.S. Army general, served as CIA director since June 2011. Prior to that, he was the top commander on the ground in Iraq and the top commander in Afghanistan following the retirement of Gen. Stanley McChrystal.
Petraeus turned over the Afghan command to Gen. John Allen in July 2011.
Petraeus had been expected to testify next week at congressional hearings on the attack on the U.S. Consulate in Benghazi, Libya, in which U.S. Ambassador Christopher Stevens and three other Americans were killed.
2014: The Year in Music [PHOTOS]