The FBI discovered that emails received by Jill Kelley, a close friend of the Petraeus family, were sent by Paula Broadwell. And as they dug deeper, the affair between Broadwell and Petraeus came to light. NBC's Andrea Mitchell reports.

New in this version: FBI search Paula Broadwell's home Monday night; officials say the FBI agent who worked with Jill Kelley, the Tampa, Fla. woman who received anonymous emails from Broadwell, was dismissed from case because he became obsessed with Kelley.

Updated at 11:36 p.m. ET: “Menacing” anonymous emails that launched the FBI investigation which ultimately brought down CIA Director David Petraeus contained references to the “comings and goings” of high-level U.S. military officials, raising concerns that someone had improperly gained access to sensitive and classified information, a source close to the recipient tells NBC News.

The first email sent anonymously to Jill Kelley, the Tampa, Fla., woman who reported the threatening emails to the FBI, in May referred to Kelley socializing with other generals in the Tampa area and suggested it was inappropriate and should stop, according to the source close to Kelley, who spoke with NBC News on condition of anonymity.

After Kelley alerted the FBI, agents began pursuing it as a possible case of cyber harassment or stalking. "The thought was she was being followed," the source said.

The anonymous emails continued -- sent from multiple alias accounts -- and some later ones in the sequence contained references to Petraeus, though not by name, the source said.

What most alarmed Kelley and the FBI, the source said, were references to "the comings and goings" of high-level generals from the U.S. Central Command, which is based at MacDill Air Force Base in Tampa, and the U.S. Southern Command, as well as Petraeus -- including events that were not on any public schedule. This raised the question as to whether somebody had access to sensitive -- and classified -- information.

Moreover, the sender of the emails had "covered her tracks pretty well," the source said.

Some members of Congress are saying that they or, at the least President Barack Obama, should have been told about the investigation of the director of the CIA while it was going on. NBC's Pete Williams reports.

Multiple government and law enforcement officials have told NBC News that FBI agents traced the emails to Paula Broadwell, Petraeus’ biographer. In the course of the investigation, the agents also discovered emails between Petraeus and Broadwell that were indicative of an extramarital affair, they said.

The source close to Kelley said that she had never met Broadwell and had no idea who she was. The source also stressed that Kelley has been active in multiple social events in the Tampa area and is purely a social friend of the Petraeus family.

Meanwhile, it has come to light that the FBI agent contacted by Kelley about the emails she received from Broadwell was removed from the case. According to officials, the agent’s supervisors said he had become infatuated with Kelley and had sent her shirtless photos of himself.

The FBI remains involved in the case, however. On Monday evening, plain-clothed FBI agents arrived at Broadwell’s home in Dilworth, N.C. around 9 p.m. Monday night for what a senior law enforcement official called a “consensual search.” The official said the search is not a raid and “not a game changer.”

Rather, the official said that the FBI is being thorough as it finishes its investigation into Broadwell and whether she violated cyber-stalking or cyber-bullying laws.

The investigation of Petraeus has concluded. Law enforcement sources tell NBC News that Petraeus is not under investigation and that they don't expect their inquiry will result in criminal charges.

The search of Broadwell's home is not expected to yield information that would lead to charges against her, the official said. At the house, agents did not respond when reporters asked for their affiliation, although WCNC in Charlotte, N.C. confirmed they were with the FBI.

NBC News has been unable to reach Broadwell for comment.

The FBI confirmed it conducted a search of the home of Paula Broadwell in relation to the investigation former CIA director David Petraeus. MSNBC's Lawrence O'Donnell discusses with Jon Meacham, author of the new book, "Thomas Jefferson: The Art of Power," and Jane Mayer, a staff writer for The New Yorker.

The new information offers clues about how federal investigators could connect a handful of anonymous emails to Broadwell, a trained intelligence officer who spent years working with some of the most secretive agencies in the world.

Federal officials who spoke with NBC News on condition of anonymity on Monday said it took agents a while to figure out the source. They did that by finding out where the messages were sent from -- which cities, which Wi-Fi locations in hotels. That gave them names, which they then checked against guest lists from other cities and hotels, looking for common names.

That led them to Broadwell, they said, noting that the pattern coincided with her travel to promote her book.

Finding the location from which the emails emanated would not have been difficult, experts say.

Some webmail services, including Yahoo and Microsoft's Outlook.com, send user IP addresses across the Web with every note, according to privacy researcher Chris Soghoian, a senior policy analyst at the American Civil Liberties Union. Those IP addresses can be used to track the physical location of a computer user connected to the Internet, sometimes without the help of an Internet service provider.

Broadwell had used a Yahoo account publicly in the past. If she used a new, fake Yahoo account for some of those anonymous emails, agents would have had an easy time gathering a list of IP addresses from the threatening emails Kelley provided to them. And even if she had used Gmail or another service that doesn't "leak" IP information, an FBI agent could have obtained such information by calling Google with a subpoena, the experts said.

Slideshow: Petraeus case: Cast of characters ISAF via Reuters file Meet the people who have been pulled into the scandal that caused Gen. David Petraeus to resign. Launch slideshow

Once there was evidence to link Broadwell to the emails, agents would have had little trouble proving probable cause and getting a warrant under the provisions of the Stored Communications Act, which would allow them to access any emails sent or received during the prior 180 days. Agents could also have sought a wiretap order and monitored Broadwell’s email in real time, though wiretaps are more challenging to obtain, and there is no indication that agents took that step.

Soghoian said the successful cyberhunt for Broadwell shows anonymity is much harder to preserve than many Internet users realize.

"We see this again and again. We saw it with the Anonymous (hacker) arrests last year. The lesson for the rest of us here us you have to go through a lot of steps to maintain anonymity, and you only have to screw up once," said Soghoian. "The FBI was able to pierce the veil of anonymity even for someone who's been trained. The government only has to get one clue. You have to be successful 100 percent of the time (when trying to hide)."

NBC News Justice correspondent Pete Williams contributed to this report.

More from Open Channel:

Follow Open Channel from NBCNews.com on Twitter and Facebook