"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," Petraeus said in a letter to colleagues, explaining his decision to step down.
"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," he said.
Petraeus, 60, had a distinguished 37-year career in the military before joining the CIA, helping turn the tide against insurgents while commanding forces in Iraq and Afghanistan. Earning praise from both sides of the political aisle, the retired four-star general took the helm of the CIA in September 2011.
Petraeus met with Obama on Thursday to offer his resignation and explain the circumstances behind it, according to a senior administration official. The president accepted Petraeus' resignation during a phone call Friday, the official 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," Obama said in a statement.
"As director of the Central Intelligence Agency, he has continued to serve with characteristic intellectual rigor, dedication and patriotism."
Petraeus assumed command of the NATO International Security Assistance Force and U.S. Forces Afghanistan in July 2010, after serving for more than 20 months as commander of U.S. Central Command. He previously commanded multinational forces in Iraq, leading the so-called surge.
The general literally wrote the book on counterinsurgency techniques by overseeing development of the Army/Marine Corps Counterinsurgency Manual.
Before his nomination as CIA director, Petraeus was considered the nation's most well-known and popular military leader since Colin Powell.
Petraeus and his wife, Holly, live in Virginia. They have two grown children.