The top FBI aide who bashed President Trump to her special-agent boyfriend has resigned.

Lisa Page, who was implicated in the Department of Justice Inspector General’s probe into official misconduct during the Clinton and Trump investigations, stepped down on Friday. She’d been reassigned to a less powerful position in recent months.

Peter Strzok, who allegedly carried on an extramarital affair with Page, was demoted to the FBI’s Human Resources Division after their anti-Trump texts came to light. He’s still in the bureau.

The same day Page resigned, former FBI chief lawyer James Baker did, too. He’d been under scrutiny for a leak of classified information relating to the Steele dossier, a report filled with racy yet unsubstantiated charges that was funded by the Hillary Clinton campaign.

Lisa Page served as legal counsel to ousted Deputy Director Andrew McCabe before thousands of her text messages with Strzok revealed widespread animus to Trump within the agency.

Page and Strzok exchanged 50,000 texts during the course of the campaign and the months that followed. Their messages, revealed in December, included comments that referred to the Republican candidate as an “idiot” and a “douche.”

The lovers, both Clinton fans, were involved in the FBI investigation of her use of a private e-mail server to handle classified information while she was secretary of state.They were also major players in the agency’s probe of the Trump campaign’s possible ties to Russia.

Strzok, the FBI’s former No. 2 counterintelligence official, was a lead investigator in both politically sensitive inquiries.

He took part in the FBI’s interview of Clinton, which occurred just days before now-fired FBI Director James Comey shut down the investigation.

Strzok also interviewed Clinton aides Huma Abedin and Cheryl Mills. He accepted both women’s denials of knowing about Clinton’s secret server while she was using it — and did not grill them thoroughly.

It was Strzok who changed the draft wording of Comey’s July 2016 statement that accused Clinton of being “extremely careless” — instead of “grossly negligent” — which was crucial to Clinton wriggling from criminal charges.

Strzok also helped interview then-National Security Adviser Michael Flynn, which led to Flynn’s firing and eventual guilty plea for lying to investigators.

Both Strzok and Page were assigned to special counsel Robert Mueller’s staff in 2017, when he launched the investigation into possible collusion between the Trump campaign and Russia. Strzok was demoted when Mueller learned of the text messages in August 2017; Page left Mueller’s staff two weeks before.

Page and Strzok also talked about a cryptic “insurance policy” that they discussed in case of a Trump electoral victory.

“I want to believe… that there’s no way he gets elected — but I’m afraid we can’t take that risk,” Strzok texted on Aug. 15, 2016. “It’s like an insurance policy in the unlikely event you die before you’re 40.”

James Baker, the former FBI chief lawyer, was closely involved with all applications to spy on US citizens — such as Trump aide Carter Page — under the Foreign Intelligence Surveillance Act.

“A great public servant retired from the FBI today,” Comey tweeted Friday. “Jim Baker’s integrity and commitment to the rule of law have benefitted our country through 5 presidents, of both parties.