TAMPA, FLA. — Former CIA Director David Petraeus was shocked to learn last summer that his mistress was suspected of sending threatening emails warning another woman to stay away from him, former staff members and friends told the AP on Monday.

Petraeus told these associates his relationship with the second woman, Tampa socialite Jill Kelley, was platonic, though his biographer-turned-lover Paula Broadwell apparently saw her as a romantic rival. Petraeus also denied to these associates that he had given Broadwell any of the sensitive military information alleged to have been found on her computer, saying anything she had must have been provided by other commanders during reporting trips to Afghanistan.

The associates spoke on condition of anonymity because they weren't authorized to publicly discuss the matters, which could be part of an FBI investigation.

Petraeus, who led U.S. military efforts in Iraq and Afghanistan, resigned his CIA post Friday, acknowledging his extramarital affair with Broadwell and expressing deep regret.

New details of the investigation that brought an end to his storied career emerged as President Barack Obama hunted for a new CIA director and members of Congress questioned why the months-long probe was kept quiet for so long.

Kelley began receiving harassing emails in May, two federal law enforcement officials said. They spoke only on condition of anonymity because they were not authorized to speak publicly about the matter.

The emails led Kelley to report the matter, eventually triggering the investigation that led Petraeus to resign as head of the intelligence agency.

FBI agents traced the alleged cyberharassment to Broadwell, the officials said, and discovered she was exchanging intimate messages with a private Gmail account. Further investigation revealed the account belonged to Petraeus under an alias.

Broadwell co-authored a biography titled “All In: The Education of General David Petraeus,” published in January. In the preface, she said she met Petraeus in the spring of 2006 while she was a graduate student at the Kennedy School of Government at Harvard, and she ended up following him on multiple trips to Afghanistan as part of her research.

But the contents of the email exchanges between Petraeus and Broadwell suggested to FBI agents that their relationship was intimate. The FBI concluded relatively quickly — by late summer at the latest — that no security breach occurred, the two senior law enforcement officials said. But the FBI continued its investigation into whether Petraeus had any role in the harassing emails.

Petraeus, 60, told one former associate he began an affair with Broadwell, 40, a couple of months after he became CIA director late last year. They mutually agreed to end the affair four months ago, but they kept in contact because she was still writing a dissertation on his time commanding U.S. troops overseas, the associate said.

FBI agents contacted Petraeus, and he was told that sensitive, possibly classified documents related to Afghanistan were found on her computer. He assured investigators they did not come from him, and he mused to his associates that they were probably given to her on her reporting trips to Afghanistan by commanders she visited in the field there. The FBI concluded there was no security breach.

Kelley, 37, served as a sort of social ambassador for U.S. Central Command, hosting parties for the general when Petraeus was commander from 2008-10.Jill Kelley regularly kept in touch with Petraeus when he became commander of the Afghan war effort, the two exchanging near-daily emails and instant messages, two of his former staffers say. But those messages were exchanged in accounts that his aides monitored as part of their duties and were not romantic, the staffers said.