WASHINGTON (AP) — The resignation of CIA director David Petraeus has brought a sudden and unexpected end to the public career of a four-star general who led U.S. troops in Afghanistan and Iraq and was thought to be a potential candidate for president. Petraeus admitted to an extramarital affair in tendering his resignation, which President Barack Obama accepted yesterday. Petraeus carried on the affair with his biographer Paula Broadwell, a reserve Army officer, according to several U.S. officials with knowledge of the situation. They spoke anonymously because they were not authorized to discuss publicly the investigation that led to the resignation. The FBI discovered the relationship by monitoring Petraeus' emails, after being alerted Broadwell may have had access to his personal email account, two of the officials said. Broadwell did not respond to voice mail or email messages seeking comment. Broadwell's biography, "All In: The Education of General David Petraeus," was written with Vernon Loeb, a Washington Post editor, and published in January. Lawmakers from both parties joined Obama in praising Petraeus. Obama said in a statement that Petraeus had provided "extraordinary service to the United States for decades" and had given a lifetime of service that "made our country safer and stronger." CIA Deputy director Michael Morell will serve as acting director, Obama said. Morell was the key CIA aide in the White House to President George W. Bush during the Sept. 11, 2001, terror attacks.