President-elect Donald Trump’s choice for defense secretary was among military officials who, the FBI concluded, received anonymous emails from the woman whose affair with then-CIA director David Petraeus led to his downfall, the Associated Press has learned.

The emails to the now retired marine general, James Mattis, and others, warning them to stay away from a socialite from Tampa, led to the discovery of Petraeus’ affair with his biographer Paula Broadwell, and revelations that he had shown classified secrets to her.

The FBI also concluded that Broadwell was the source of the anonymous emails.

According to an FBI report and a US official, agents interviewed Mattis, who said he always had proper interactions with the socialite, Jill Kelley. The official spoke on condition of anonymity because the official was not authorized to discuss the investigation publicly.

The bizarre scandal surfaced four years ago but has crept back into headlines in recent weeks because Petraeus is among candidates Trump is considering to become secretary of state.

Petraeus resigned as CIA director in November 2012, and later pleaded guilty to one misdemeanor charge of mishandling classified information. He was also fined $100,000 and remains on probation.

The scandal unfolded when the FBI investigated anonymous emails sent to high-ranking military officials and to Kelley’s husband, warning them about what was described as Kelley’s inappropriate behavior toward the men.

One of the officials who received an anonymous email was Mattis, who Trump announced last week would become his nominee for secretary of defense.

Mattis had been interviewed by the FBI about the email and his statement was memorialized in FBI reports. He told investigators he could not understand why anyone would send him a warning because he always had above-board interactions with Kelley.

He told the FBI that she held an honorary ambassador title, and said they met when he served as a top officer at US Central Command headquarters in Tampa.

Mattis did not immediately respond to a message left with Trump’s transition team.

Emails between Mattis and Kelley were released last year under the Freedom of Information Act. In some, Mattis referred to Kelley as “Young Jill”. Kelley has said she never behaved inappropriately with Petraeus or any of the military officials she was emailing.

Separately, agents from the Naval Criminal Investigative Service Office of Special Projects had interviewed Mattis about counterintelligence aspects of the case, a US official told the AP.

It was considered by the agents to be an especially sensitive assignment because of the allegations against Petraeus about mishandling classified information. The official spoke on condition of anonymity because the official was not authorized to discuss details of the investigation publicly.

Broadwell was not accused of a crime. She told CBS This Morning that “it was a bit of a shocker that Petraeus was being considered for a cabinet position”, but said both she and Petraeus should be allowed to move on with their lives.

In a text message sent on Friday to the AP, Kelley wrote: “Paula Broadwell’s stalking brought months of unwanted terror to my innocent family, not to mention the national security breaches she created by her anonymous emails to our most senior generals by illegally accessing General Petraeus’ government emails – based on her irrational & sexist suspicions.

“Of course she wants to ‘move on’ after she ruined countless careers and reputations of the victims she stalked because her affair ended.”

Broadwell responded in a statement: “These false narratives are increasingly absurd.

“It’s unfortunate that while most have sought to go on with their lives in a humble and dignified manner, one person alone continues obfuscate the truth by gas lighting others.”