(CNN) — Only two people know how the affair started, but the world knows now about its inglorious end.
Admitting to the extramarital affair, David Petraeus stepped down as director of the CIA on Friday in a surprise move that shocked the intelligence community just days after President Barack Obama was re-elected.
Immediate praise for the man poured in. The president hailed Petraeus’ dedication and patriotism, while leaders from both parties said he would be missed.
It appeared an abrupt end to a spectacularly successful career in public service.
“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.
According to a U.S. official, the FBI had a tip that Petraeus was involved with his biographer, Paula Broadwell, and investigated the alleged affair to determine whether it posed a security risk.
The FBI was not investigating Petraeus for wrongdoing. The concern was that he could potentially be blackmailed or put “in a vulnerable spot,” the official said.
Broadwell spent a year with Petraeus in Afghanistan interviewing him for the book she co-wrote, “All In: The Education of General David Petraeus.”
It is not clear whether Broadwell is the woman with whom Petraeus has admitted having an affair. CNN has not been able to reach Broadwell for comment.
Other sources close to the CIA director told HLN anchor Kyra Phillips that the woman involved in the affair was not under Petraeus’ command. The woman was not a member of the armed forces and not a CIA employee, they 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.
Director of National Intelligence James Clapper hailed Petraeus, saying his “decision to step down represents the loss of one of our nation’s most respected public servants.”
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, said the official.
“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.”
The president expressed confidence that the CIA will continue to move forward, under the direction of Acting Director Michael Morell.
Morrell, a career agency officer, was sworn in as deputy director of the CIA in May 2010. He previously served as associate deputy director and director for intelligence.
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 United States 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.
But his reputation was potentially tarnished by the controversy over the terror attack on the U.S. mission in Benghazi, Libya, that killed Ambassador Christopher Stevens and three other Americans in September.
Petraeus was expected to testify before the Senate Intelligence Committee next week on the Benghazi attack. Morrell will take his place, according to the office of Sen. Dianne Feinstein, who is chairman of that committee.
“I wish President Obama had not accepted this resignation, but I understand and respect the decision. David Petraeus is one of America’s best and brightest, and all Americans should be grateful for his service,” she said.
Rep. Peter King, chairman of the House Committee on Homeland Security, described Petraeus as a “true American patriot.”
“This is a real loss for the country; a real loss for the CIA,” he told CNN’s Erin Burnett.
Petraeus and his wife, Holly, live in Virginia. They have two grown children.
By Dana Ford, CNN.
CNN’s Carol Cratty, Terry Frieden, Suzanne Kelly and Jill Dougherty contributed to this report.
™ & © 2012 Cable News Network, Inc., a Time Warner Company. All rights reserved.