Andrew McCabe, the former head of the FBI, is suing the bureau and the Justice Department for his abrupt firing last year. McCabe alleges in the suit filed Thursday that he was ousted “for his refusal to pledge allegiance to a single man”—President Donald Trump.

“It was Trump’s unconstitutional plan and scheme to discredit and remove DOJ and FBI employees who were deemed to be his partisan opponents because they were not politically loyal to him,” the complaint alleges. “Plaintiff’s termination was a critical element of Trump’s plan and scheme.”

McCabe goes on to charge that “Trump demanded Plaintiff’s personal allegiance, he sought retaliation when Plaintiff refused to give it, and [former Attorney General Jeff] Sessions, [FBI Director Christopher] 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.”

Wray and Attorney General William Barr are named as co-defendants in the 48-page federal suit, which describes a chaotic, rushed effort to oust McCabe before he was eligible to collect his pension—as Trump blasted him across social media.

Just days before he was fired, a Justice Department official allegedly admitted to McCabe that the agency was not following established practices and procedures in connection with the disciplinary process, saying, “We’re making it up as we go along.”

McCabe has long been one of the president’s top targets and clashed with him soon after Trump took office.

According to the suit, in February 2017, Trump had his then chief of staff, Reince Priebus, ask McCabe—then the deputy director—to publicly refute a news story that made the new president look bad. When McCabe declined, “Priebus said that Plaintiff and the FBI were ‘not being good partners’ to Trump,” the suit says.

After Trump fired James Comey as FBI director several months later, McCabe temporarily took his post, and the FBI’s investigation into how the Kremlin interfered in the 2016 presidential election continued unhindered—much to the president’s chagrin. Trump homed in on McCabe as a bad actor, claiming that support from Clinton allies for his wife’s unsuccessful bid for state office meant McCabe needed to recuse himself from the investigation.

McCabe didn’t step back, though, and the president began sending dozens of tweets castigating him.

The situation only got worse. Barely a day before McCabe would have become eligible for his retirement pension, and late on a Friday, then-Attorney General Jeff Sessions fired him from the post. Sessions said he did so because the FBI’s inspector general found he shared information with the media without authorization and lacked candor when speaking under oath to internal investigators.

But among veterans of federal law enforcement community, the move was broadly seen as a political attack designed to punish McCabe for the FBI’s investigation of the president. Trump’s personal lawyer, meanwhile, praised the firing and said he hoped Special Counsel Robert Mueller would be ousted next.

A month later, the inspector general released a report saying McCabe engaged in misconduct and misled investigators—findings McCabe strongly denied.

After his firing, McCabe became a hero to Trump’s many opponents. A GoFundMe page to cover his legal expenses raised more than $500,000, and his book topped bestseller lists.

He isn’t the first Trump foil to take legal action against the Justice Department. Peter Strzok, a senior FBI counterintelligence agent who worked on the Russia probe, sued the FBI and the DOJ earlier this week for wrongful termination. He argues that the firing violated his rights under the First and Fifth Amendments. Strzok was removed from Mueller’s team after the special counsel learned he and an FBI lawyer, Lisa Page, exchanged numerous texts criticizing Trump and his supporters. He was subsequently fired from the FBI.