Former FBI lawyer Lisa Page sued the agency and US Department of Justice on Tuesday for allegedly illegally releasing private documents involving her to the press — namely, hundreds of text messages between her and her special-agent boyfriend.

The lawyer also fired back against President Trump’s comments about her in past months, including when he called her “incompetent,” “corrupt,” “pathetic,” “stupid,” a “dirty cop,” a “loser,” a “clown,” “bad people,” “sick people,” a “lover,” a “great lover,” a “wonderful lover,” a “stupid lover,” and “lovely,” her suit says.

“The President’s tweets about Ms. Page have been retweeted and favorited millions of times,” the plaintiff lawyer lamented.

The government agencies’ release of her private texts were designed “to promote the false narrative that Plaintiff and others at the FBI were biased against President Trump, had conspired to undermine him, and otherwise had engaged in allegedly criminal acts, including treason,” according to Page’s lawsuit.

The lawyer landed in the public spotlight in late 2017 after she says the DOJ secretly released, in the dead of night, 375 texts between her and beau Peter Strzok, who at the time was the lead investigator into alleged Russian interference in the 2016 presidential election and Hillary Clinton’s use of a private email server for federal government communications.

The pair mocked Trump in their texts, leading critics to claim the probe was biased against him.

But “DOJ and/or FBI officials disclosed the messages to reporters for multiple improper reasons, including to elevate DOJ’s standing with the President following the President’s repeated public attacks of the Department and its head, Attorney General Jefferson B. Sessions III,” the lawsuit says.

“They did so by summoning DOJ beat reporters to the Department to review the messages at night, prohibiting the reporters from copying or removing the set of messages from the building, and instructing them not to reveal DOJ as the source.

“This clandestine approach is inconsistent with the disclosure of agency records for transparency purposes or to advance the public interest.

“Ultimately, [the Office of Inspector General] found no evidence of bias affecting any investigative decisions in the FBI’s Midyear investigation, but the Inspector General’s report, issued six months after the December 12 disclosure, came too late,” Page alleges in the documents.

“By then, Defendants’ unlawful conduct had turned Plaintiff into a subject of frequent attacks by the President of the United States, as well as his allies and supporters.”

“In the two years since the December 12 disclosure, the President has targeted Ms. Page by name in more than 40 tweets and dozens of interviews, press conferences, and statements from the White House, fueling unwanted media attention that has radically altered her day-to-day life.”

At one point, the president faked an orgasm to mock her texts with Strzok, which Page said in a recent interview has led her to break her silence.

Page resigned from the FBI in May 2018.

Strzok was demoted and eventually fired. He is suing for reinstatement.

The DOJ, which helps oversee the FBI, declined comment to The Post on Tuesday.