WASHINGTON (AP) — Former FBI Deputy Director Andrew McCabe, a frequent target of President Donald Trump's ire, sued the FBI and the Justice Department on Thursday over his firing.

The lawsuit, the second this week from an ex-FBI official challenging the circumstances of his termination, says the firing was part of Trump's plan to rid the bureau of leaders he perceived as disloyal to him.

The complaint contends that the two officials responsible for demoting and then firing McCabe — FBI Director Chris Wray and former Attorney General Jeff Sessions — created a pretext to force him out in accordance with the president's wishes.

The stated reason for the firing was that McCabe had misled investigators over his involvement in a news media leak, but McCabe says the real reason was "his refusal to pledge allegiance to a single man."

"Trump demanded Plaintiff's personal allegiance, he sought retaliation when Plaintiff refused to give it, and Sessions, Wray, and others served as Trump's personal enforcers rather than the nation's highest law enforcement officials, catering to Trump's unlawful whims instead of honoring their oaths to uphold the Constitution," the lawsuit says.

The federal complaint accuses the FBI and Justice Department of straying from established policies, with Wray refusing to tell McCabe why he was being fired and a senior Justice Department lawyer telling McCabe's own lawyer that they were "making it up as we go along."

It says the government sped up disciplinary proceedings so McCabe could be fired ahead of his planned retirement and without receiving full benefits. The lawsuit asks for a judge to declare McCabe's firing unconstitutional and to declare him entitled to his full pension and other benefits.

Spokespeople for the FBI and Justice Department declined to comment Thursday.

McCabe has been a target of Trump's attacks since even before he was elected, after news emerged in the fall of 2016 that McCabe's wife had accepted campaign contributions from former Virginia Gov. Terry McAuliffe during an unsuccessful run for the state Senate there. McAuliffe is a close ally of Bill and Hillary Clinton, who was being investigated at the time for her use of a personal email server.

The attacks continued after Trump's victory, with the president working to force McCabe from government by pressuring Sessions, Deputy Attorney General Rod Rosenstein and others, the lawsuit says.

After McCabe refused on policy grounds to publicly refute a news story about contacts between Russia and Trump campaign associates, the then-White House chief of staff Reince Priebus told McCabe that he and the FBI were "not being good partners" to Trump, according to the complaint.

"Trump's purge targeted Plaintiff in particular because Trump had already decided during the 2016 U.S. presidential campaign that Plaintiff was his partisan enemy by virtue of Plaintiff's marriage," the lawsuit said.

McCabe was fired in March 2018 after a Justice Department inspector general report found he had repeatedly misstated his involvement in a news media disclosure regarding FBI investigations involving Clinton. The watchdog office referred the matter to the U.S. Attorney's Office in Washington, which has been investigating.

McCabe has denied any wrongdoing, and has said that when he felt his answers were being misunderstood, he tried to correct them.

On Tuesday, former FBI agent Peter Strzok, who was fired over derogatory text messages he sent about Trump, also sued the FBI and Justice Department. He said the FBI had been influenced by "unrelenting pressure" from the president when it fired him.

McCabe spent 21 years with the FBI. He became acting director in May 2017 after the president fired former director James Comey.

More From WIBX 950