NBC's Brian Williams and NBC's Andrea Mitchell report on the resignation of well-regarded former General David Petraeus from the CIA after he admitted an affair.

WASHINGTON -- CIA Director David Petraeus resigned Friday, citing an extramarital affair and "extremely poor judgment."

As first reported by NBC News, Petraeus disclosed the affair in a letter released to the CIA work force on Friday afternoon, writing: "Such behavior is unacceptable, both as a husband and as the leader of an organization such as ours."

Petraeus told President Barack Obama of his affair and offered his resignation during a meeting Thursday, a senior official told NBC News.

In a statement, Obama said he accepted Petraeus’s resignation on Friday.

"By any measure, through his lifetime of service, David Petraeus has made our country safer and stronger," Obama said of the four-star general, who led American forces in Iraq and Afghanistan.

Petraeus' biographer, Paula Broadwell, is under FBI investigation for improperly trying to access his email and possibly gaining access to classified information, law enforcement officials told NBC News on Friday. She is the author of Petraeus' biography, "All In." Broadwell had extensive access to Petraeus in Afghanistan and has given numerous television interviews speaking about him.

Law enforcement and multiple U.S. officials told NBC News that emails between Petraeus and Broadwell were indicative of an extra-marital affair.

Broadwell could not be reached by NBC News for comment.

David Petraeus a battlefield 'hero' and savvy Washington insider

Petraeus himself is not under investigation.

A U.S. military official and long-time aide to Petraeus told NBC News the director resigned "because he screwed up."

"In his mind, in his views, with his code of ethics and morals, he did a very dishonorable thing," the official said. "This had nothing to do with Benghazi, nothing to do with his relationship with the White House."

Petraeus was appointed CIA director in April 2011, replacing Leon Panetta, who moved to the Pentagon to become defense secretary.

Petraeus served as commander of the war in Afghanistan in 2010-2011. Before that, he served as commander of the U.S. Central Command and as the commanding general of U.S. forces in Iraq. Because of those roles, he was seen as bringing a “customer’s eye” to the intelligence job.

Sen. Dianne Feinstein, D-Calif., chair of the Senate Intelligence Committee, told NBC News that Petraeus’s personal mistake should not have led to his departure.

"I would have stood up for him," Feinstein said in response to his indiscretion. "I wanted him to continue. He was good, he loved the work, and he had a command of intelligence issues second to none."

Mandel Ngan / AFP - Getty Images file General David Petraeus, center, takes the oath of office as the next director of the CIA from Vice President Joe Biden, right, as Petraeus's wife, Holly, watches on Sept. 6, 2011 during a ceremony at the Roosevelt Room of the White House in Washington, D.C.

Feinstein said she respects Obama’s decision to accept the Petraeus resignation, but wishes he hadn't.

She also said Petraeus will not need to testify at hearings she is chairing next week into the attack on the U.S. consulate in Benghazi, Libya. Ambassador Christopher Stevens and three other Americans were killed in the attack.

Rep. Peter King, R-NY, chairman of the House Committee on Homeland Security, said he regrets Petraeus's resignation. "General Petraeus is one of America's most outstanding and distinguished military leaders and a true American patriot," King said in a statement.

Sen. John McCain, R-Ariz., said it was Petraus's "genius" that was responsible "for the success of the surge in Iraq."

"General David Petraeus will stand in the ranks of America's greatest military heroes," McCain said in a statement.

Multiple sources tell NBC News that Mike Morrell, the deputy CIA director and a longtime CIA officer, would likely be offered the job as acting director, with the understanding that he may be elevated to the job permanently.

That's how George Tenet got the job, first as deputy director in July 1995, then acting director following the resignation of John Deutch in December 1996 and finally as director in July 1997, staying on in the Bush administration.

Morrell is a longtime CIA analyst and was an eyewitness to two of the most momentous events in recent U.S. history. He was traveling with President George W. Bush on Sept. 11, 2001, as the president's briefer, and was in the Situation Room on May 1, 2011, as deputy CIA Director, when Navy SEALs killed Osama bin Laden.

Morell began his agency career as an analyst tracking international energy issues and subsequently worked for 14 years as an analyst and manager on East Asia. In 1999, he was appointed director of the Office of Asian Pacific and Latin American Analysis. He also has served as a presidential briefer, as chief of the staff that produces the president's daily briefing, and as an executive assistant to CIA Director George J. Tenet.

From 2003 until 2006, he served overseas. Upon his return, he was briefly deputy director for intelligence at the National Counterterrorism Center before being asked to become associate deputy director at the CIA.

NBC's Andrea Mitchell reports on the resignation of CIA Director David Petraeus after citing an extra-marital affair and apologizing for poor judgment.

Here is the full text of Petraeus' letter:

HEADQUARTERS Central Intelligence Agency 9 November 2012

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. 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. 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.

Thank you for your extraordinary service to our country, and best wishes for continued success in the important endeavors that lie ahead for our country and our Agency. With admiration and appreciation,

David H. Petraeus

Andrea Mitchell is NBC News’ chief foreign affairs correspondent. Robert Windrem is NBC News’ senior investigative producer. NBC News Chief White House Correspondent Chuck Todd contributed to this report.

More content from NBCNews.com:

Follow US news from NBCNews.com on Twitter and Facebook