WASHINGTON — The F.B.I. investigation that led to the sudden resignation of David H. Petraeus as C.I.A. director on Friday began with a complaint several months ago about “harassing” e-mails sent by Paula Broadwell, Mr. Petraeus’s biographer, to another woman who knows both of them, two government officials briefed on the case said Saturday.

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 several officials who spoke of the investigation on the condition of anonymity. They also discovered that Ms. Broadwell possessed certain classified information, one official said, but apparently concluded that it was probably not Mr. Petraeus who had given it to her and that there had been no major breach of security. No leak charges are expected to be filed as a result of the investigation.

The identity of the woman who complained about the harassing messages from Ms. Broadwell has not been disclosed. She was not a family member or in the government, the officials said, and the nature of her relationship with Mr. Petraeus was not immediately known. But they said the two women seemed to be competing for Mr. Petraeus’s loyalty, if not his affection.

One Congressional official who was briefed on the matter said senior intelligence officials explained that the F.B.I. investigation “started with two women” — evidently Ms. Broadwell and the woman who complained about her e-mails. “It didn’t start with Petraeus, but in the course of the investigation they stumbled across him,” said the Congressional official. “We were stunned.”