CIA Director David Petraeus has resigned his position, citing personal reasons and an extramarital affair.
"Yesterday afternoon, I went to the White House and asked the president to be allowed, for personal reasons, to resign from my position as D/CIA," he said in a statement. "After being married for over 37 years, I 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. This afternoon, the president graciously accepted my resignation."
Sources familiar with the investigation tell ABC News that Petraeus was having an affair with his biographer, Paula Broadwell.
The FBI was investigating Broadwell, for strange activity on the Internet when it discovered some emails that raised concerns, according to officials familiar with the probe.
WATCH: Paula Broadwell interviewed on "Around The World with Christiane Amanpour"
Petraeus, a former Army general who led the surge into Iraq under former President Bush and also led U.S. troops in Afghanistan before taking over the CIA, is one of the most respected and influential generals of his time. His wife, Holly, has worked with the Obama administration to help military families.
He was scheduled to testify next week on Capitol Hill behind closed doors about the death of four Americans, including two working for the CIA. They died at the U.S. consulate in Benghazi, Libya, Sept. 11. Holes in security at the consulate have been the subject of an internal government investigation at the State Department and a congressional inquiry.
A U.S. official stressed that Petraeus' decision to step down had "absolutely nothing to do with Benghazi." Planned congressional hearings on the Benghazi incident will continue as planned with CIA Deputy Director Michael Morell filling in for Petraeus as acting director.
A senior U.S. official also told ABC News that Morell is expected to be named the permanent replacement atop the CIA.
President Obama reacted to the resignation with a written statement.
"David Petraeus has provided extraordinary service to the United States for decades," Obama said. "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."
There was no mention of the affair or the circumstances of Petraeus' resignation.
"Today, I accepted his resignation as director of the Central Intelligence Agency," Obama continued. "I am completely confident that 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.
"Going forward, my thoughts and prayers are with Dave and Holly Petraeus, who has done so much to help military families through her own work. I wish them the very best at this difficult time," the president added.
The news shocked official Washington. Petraeus was perhaps the military's most-respected general of his generation. He was a problem-solver entrusted with key roles by two presidents from different parties.
Sen. Dianne Feinstein, D-Calif., chairman of the Senate Intelligence Committee, said she wished that Obama had not accepted Petraeus' resignation.
"I wish President Obama had not accepted this resignation, but I understand and respect the decision," Feinstein said in a statement. "This is an enormous loss for our nation's intelligence community and for our country."
In his statement, Petraeus said, "As I depart Langley, I want you to know that it has been the greatest of privileges to have served with you, the officers of our Nation's Silent Service, a work force that is truly exceptional in every regard. Indeed, you did extraordinary work on a host of critical missions during my time as director, and I am deeply grateful to you for that.
"Teddy Roosevelt once observed that life's greatest gift is the opportunity to work hard at work worth doing. I will always treasure my opportunity to have done that with you and I will always regret the circumstances that brought that work with you to an end," Petraeus added.
There were no further details about the circumstances surrounding the affair or Petraeus' departure.