“[Broadwell] clearly thought something was going on” and thought she was in a “lovers triangle,” the official said.

The threatened woman was not Petraeus’ wife, the sources said, and the Washington Post reported that she did not work for the CIA.

The sources declined to disclose the woman’s identity or her relationship with the 60-year-old CIA chief.

But what began as a probe of Broadwell’s alleged e-mail threats evolved into an investigation that took in Petraeus’ personal e-mail account, which agents feared was involved in a national-security breach.

That, in turn, led investigators to a series of steamy e-mails between West Point grads Petraeus and Broadwell — including a graphic reference to “sex under a desk,” Newsmax reported.

News of the affair abruptly ended Petraeus’ military and intelligence career.

On Friday, President Obama accepted the resignation of the former four-star general, who led the CIA for 14 months. “Such behavior is unacceptable, both as a husband and as the leader of an organization such as ours,” Petraeus said in a letter to CIA colleagues.

Petraeus met Broadwell in 2006 when he spoke at Harvard University’s Kennedy School of Government, where she was studying.

Afterward, Broadwell and other students with military backgrounds dined with Petraeus. He gave Broadwell his card and invited her to “bounce ideas off him.”

They got closer in 2008 when Petraeus invited her to go running in Washington.

A dash from the Pentagon to the Washington Monument “became a test for me . . . the talk turned to heavy breathing,” Broadwell recounted in her book, “All In: The Education of General David Petraeus,” published this year.

Broadwell was embedded with Petraeus when he led US troops in Afghanistan in 2010 and 2011. She’s also reported to have called Petraeus by the nickname “Peaches,” which was given to him by a classmate at West Point.

Broadwell broke off the relationship in September 2011, when Petraeus was sworn in as head of the CIA. Petraeus continued to pursue her with numerous e-mails, reports say.

Petraeus has been married for 37 years to Holly Petraeus, a top official in the Consumer Financial Protection Bureau. They met at West Point, where her father was superintendent.

Broadwell lives in a tony portion of Charlotte, NC, with her radiologist husband, Scott, and their two sons.