WASHINGTON -- The FBI investigation that led to the resignation of CIA Director David Petraeus started with a complaint several months ago that Paula Broadwell, his biographer and paramour, was sending harassing emails to a third person, a U.S. official told The Associated Press.

FBI agents discovered exchanges between Broadwell, a West Point graduate and Army Reserve officer, and Petraeus, the retired four-star general who commanded troops in Iraq and Afghanistan, that revealed they were having an affair, according to the official.

Investigators said the emails raised the possibility of security breaches that needed to be addressed directly with Petraeus because his emails in the matter were in most instances from a personal account, rather than his CIA one.

Details about the third person were not immediately available. The official was not authorized to publicly discuss the investigation and spoke only on condition of anonymity.

The sudden and unexpected end of a career that many thought might lead to a run for the presidency came on Friday. Petraeus admitted an extramarital affair in tendering his resignation, which President Barack Obama accepted.

advertisement | advertise on newsday

Petraeus' deputy, Michael Morell, will serve as acting director, Obama said. The leadership change comes as the administration and the CIA struggle to defend security and intelligence lapses before the Sept. 11 attack that killed the U.S. ambassador to Libya and three other Americans.

Petraeus, 60, has been married for 38 years to Holly Petraeus. They have two children.

Petraeus, who became CIA director in September 2011, was known as a shrewd thinker and hard-charging competitor.

In the preface to "All In: The Education of General David Petraeus," Broadwell said she first met Petraeus in 2006. After Obama put Petraeus in charge in Afghanistan in 2010, Broadwell decided to expand her research of the general into an authorized biography. Broadwell made many trips to Afghanistan, with unprecedented access to Petraeus. When Petraeus took the job at the CIA, she remained in close contact with him.