WASHINGTON -- CIA Director David Petraeus abruptly resigned Friday after admitting to an extramarital affair in a shocking end to a 37-year career in which he rose to become the Army's leading counterinsurgency strategist, the top U.S. commander in Iraq and Afghanistan and then head of the country's premier spy agency."After being married for over 37 years, I showed extremely poor judgment by engaging in an extramarital affair," Petraeus said in a statement sent 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 affair was discovered during an FBI investigation, according to officials briefed on the developments.Petraeus carried on the affair with his biographer and reserve Army officer Paula Broadwell, according to several U.S. officials who spoke anonymously because they were not authorized to discuss the matter publicly.The FBI discovered the relationship by monitoring Petraeus' e-mails, after being alerted that Broadwell may have had access to his personal e-mail account, two of the officials said.Broadwell did not respond to voice mail or e-mail messages seeking comment.Petraeus' departure after only 14 months on the job and three days after President Barack Obama won re-election roiled Washington's national security and political bureaucracies and continued a disruptive trend in which the CIA has seen four leaders depart in just eight years. While other directors have left under clouds, it is the first time in the CIA's 65-year history that the nation's top spy has lost his job over adultery.Petraeus, who turned 60 on Wednesday, said in his statement that he went to the White House on Thursday to seek Obama's permission to resign.He didn't comment on the status of his marriage to his wife, Holly, who worked closely with military families while he was on active duty and now handles veterans' financial matters in the Consumer Finance Protection Bureau. They met while Petraeus was a cadet at the U.S. Military Academy at West Point, where her father was the academy superintendent.The precise circumstances that prompted Petraeus to make his adultery public and to resign weren't immediately known. But his statement indicated that the affair was recent.Keeping it secret could have become a potentially crippling security breach had a foreign power learned of it and used it to try to compromise or blackmail Petraeus.If he committed adultery while in the Army, Petraeus could have been court-martialed.Petraeus has been at the center of a political storm over a Sept. 11 attack on the U.S. Consulate and the CIA station in Benghazi, Libya, since it emerged last week that two of the four Americans who were killed were former Navy SEALs on contract to the CIA as security officers.The U.S. ambassador to Libya and another State Department employee also died.A former aide to Petraeus who has known the general for two decades said he had exchanged e-mails with him since the scandal broke, and that Petraeus was adamantly against news of his resignation being spun into a conspiracy theory involving the Benghazi tragedy."The general insists that he felt this was the right thing to do," said the former aide, who spoke on condition of anonymity because of the sensitivity of the situation. "He insisted that this has nothing to do with Benghazi, nothing to do with Libya, nothing to do with his relationship with the president. Actually, the president took 24 hours to decide on the resignation."Obama made no reference to the reason for the resignation. He said that the retired four-star general "has provided extraordinary service to the United States for decades. 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."As CIA director, Obama added, Petraeus "has continued to serve with characteristic intellectual rigor, dedication and patriotism. By any measure, through his lifetime of service David Petraeus has made our country safer and stronger."This report includes material from The Associated Press.