The scandal that brought down CIA director David Petraeus started with harassing emails sent by his biographer and lover, Paula Broadwell, to another woman, and eventually led the FBI to discover the affair, sources said.
Retired four-star general Mr Petraeus quit on Friday after admitting an extramarital relationship.
That probe led agents to her email account, which uncovered the relationship with 60-year-old Mr Petraeus, acclaimed for his leadership of the wars in Iraq and Afghanistan. The identity of the other woman and her connection with Ms Broadwell were not immediately known.
Concerned that the emails he exchanged with Ms Broadwell raised the possibility of a security breach, the FBI brought the matter up with Mr Petraeus directly, according to the official, who spoke anonymously because he was not authorised to publicly discuss the investigation.
The FBI approached the CIA director because his emails in the matter were in most instances sent from a personal account, not his CIA one. Mr Petraeus decided to resign, abruptly ending a high-profile career that might have culminated with a run for the US presidency, a notion he was believed to be considering.
"Such behaviour is unacceptable, both as a husband and as the leader of an organisation such as ours," Mr Petraeus wrote to his staff. He handed his resignation letter to President Barack Obama on Thursday, stunning many in the White House, the CIA and Congress. The news broke in the media before the House of Representatives and Senate intelligence committees had been briefed, officials said.
The head of the US Senate Intelligence Committee has said she wants to know why the FBI did not tell her sooner that agents were investigating an extramarital affair by Mr Petraeus.
Dianne Feinstein told Fox News Sunday that she first learned about the matter from the media late last week. Ms Feinstein said she called Mr Petraeus twice on Friday and was dumbstruck when he acknowledged the affair. The California Democrat says the news was "like a lightning bolt".
Ms Feinstein said she has now been briefed by the FBI but wants to know why the bureau did not notify her sooner because of the national security implications. Ms Feinstein said she initially did not want Mr Obama to accept Petraeus' resignation, but realises now he had no choice.