CIA Director David H. Petraeus resigned Friday and admitted to having an extramarital affair, bringing a surprisingly abrupt end to his brief tenure at the spy agency as well as his decorated career in national security.

Petraeus, a retired four-star U.S. Army general once considered a potential presidential candidate, met with President Obama on Thursday and said he was prepared to step down because of the affair. Obama accepted the resignation in a phone call to Petraeus on Friday, officials said.

"After being married for over 37 years, I showed extremely poor judgment by engaging in an extramarital affair," Petraeus said in a statement distributed Friday to the CIA workforce. "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."

The sudden departure created turmoil in the Obama administration's national security team just days after the president's reelection. That team is expected to see a series of changes in the coming months, but many believed that Petraeus would remain in his position.

In a statement, Obama said Petraeus has "provided extraordinary service to the United States for decades," adding that "through his lifetime of service David Petraeus has made our country safer and stronger."

Although the statement did not directly address Petraeus's reason for resigning, the president said that his "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."

Holly Petraeus is an assistant director of the U.S. Consumer Financial Protection Bureau, charged with advocating on behalf of service members and their families. The two had met in 1973 at the U.S. Military Academy at West Point, where Holly's father was superintendent.

Petraeus was scheduled to testify next week on Capitol Hill in hearings on the deaths of four Americans, including the U.S. ambassador and two CIA security officers, in Libya in September. U.S. officials said Friday that the controversy surrounding that attack - and the administration's shifting explanations for it - played no role in Petraeus's decision to resign.

Petraeus had traveled to Libya and Jordan in recent weeks. CIA officials declined to explain the timing of his resignation, or discuss what prompted his decision to admit to the affair. Petraeus's 14-month tenure as CIA director is one of the shortest in agency history.

Michael J. Morell, who served as Petraeus's deputy at the CIA, is serving as interim director, a position he occupied for several months before Petraeus was sworn in. Morell is seen as a possible candidate to replace Petraeus, but there are others, including Michael G. Vickers, a former CIA paramilitary officer now serving as Undersecretary of Defense for Intelligence.

Petraeus came into the CIA job after a highly decorated Army career that included command of the war efforts in Iraq and Afghanistan, and made him one of the most highly recognized officers of his generation.

On Capitol Hill, he was regarded with reverence by many lawmakers. Sen. Dianne Feinstein (D-Calif.), chairman of the Senate Intelligence Committee, said Friday that she believed Petraeus's infidelity did not require him to resign.

"I wish President Obama had not accepted this resignation, but I understand and respect the decision," Feinstein said in a statement. She described Petraeus's resignation as an "enormous loss for our nation's intelligence community and for our country."

Sen. John McCain of Arizona, the ranking Republican on the Senate Armed Services Committee, also praised Petraeus's service in a statement. "Our thoughts and prayers are with him and his family," he said.