When F.B.I. agents following up on the complaint began to examine Ms. Broadwell’s e-mails, they discovered exchanges between her and Mr. Petraeus that revealed that they were having an affair, said the official, who spoke of the investigation on the condition of anonymity.

The person who complained about harassing messages from Ms. Broadwell, according to the official, was not a family member or a government official. One Congressional official who was briefed on the matter on Friday said senior intelligence officials had explained that the F.B.I. investigation “started with two women.”…

The government official dismissed a range of media speculation that the F.B.I. inquiry might have focused on leaks of classified information to the press or even foreign spying. “People think that because it’s the C.I.A. director, it must involve bigger issues,” the official said. “Think of a small circle of people who know each other.”…

Web-based e-mail like Gmail and Yahoo Mail can be quite vulnerable to hacking, and it is possible that F.B.I. experts were studying whether Mr. Petraeus’s accounts had been compromised.