U.S. Gen. David Petraeus abruptly resigned as director of the Central Intelligence Agency after admitting he had an extramarital affair.

Petraeus, who turned 60 on Wednesday, asked President Barack Obama to accept his resignation on Thursday, and on Friday the president accepted.

Petraeus said he regretted the circumstances that brought his work to an end.

“Such behavior is unacceptable, both as a husband and as the leader of an organization such as ours,” he said in his resignation letter.

The retired four-star general, who led the U.S. military campaigns in Iraq and Afghanistan, was married to Holly Petraeus for 38 years.

The two met when Petraeus was a cadet at the U.S. Military Academy. She was the daughter of the academy superintendent.

In a statement issued Friday, Obama described Petraeus as an “outstanding general officer of his generation” who helped put the wars in Iraq and Afghanistan 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,” said Obama. “By any measure, through his lifetime of service David Petraeus has made our country safer and stronger.”

While Obama did not mention the reasons behind the resignation, he offered his thoughts and prayers to Petraeus and his wife during a “difficult time.”

Obama also thanked Holly Petraeus for her work helping military families with financial issues.

Michael Morell, deputy director of the CIA, will serve as acting director of the agency, said Obama.

“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,” said Obama.

Before joining the CIA, Petraeus was credited with salvaging the U.S. war in Iraq.

Former president George W. Bush sent Petraeus to Iraq in February 2007, at the peak of sectarian violence. The general oversaw the addition of 30,000 U.S. troops and helped the military work more closely with Iraqi forces.

"His inspirational leadership and his genius were directly responsible -- after years of failure -- for the success of the surge in Iraq," Sen. John McCain said Friday.

After Iraq, Petraeus was named commander of U.S. Central Command, overseeing all U.S. military operations in the greater Middle East, including Afghanistan and Pakistan. He later took over for top U.S. commander in Afghanistan Gen. Stanley McChrystal, who was relieved of duty in June 2010 for controversial comments made to Rolling Stone magazine.

The director of national intelligence, James Clapper, said Petraeus' departure represented "the loss of one of our nation's most respected public servants. From his long, illustrious army career to his leadership at the helm of CIA, Dave has redefined what it means to serve and sacrifice for one's country."

With files from The Associated Press