Washington (CNN) Former acting FBI Director Andrew McCabe is suing the Justice Department and FBI over his firing last spring and accusing President Donald Trump of politically retaliating against him.

McCabe is asking a federal court in Washington to reinstate him as deputy director of the FBI so he can earn a full pension, which he was deprived of by being fired. He said Trump had "constitutionally improper motives for removing" him from government service.

He was dismissed hours before his retirement date following a report from the Justice Department's inspector general that concluded he improperly disclosed information to the media and lacked candor in interviews with federal investigators. McCabe, who worked for the FBI for two decades and was a senior leader in 2016 through 2018, including after FBI Director James Comey's firing and the early days of the Mueller investigation, had become a target of Trump's heckling on Twitter.

Trump had torn into McCabe's wife's Democratic political ties after she had run for state senate in Virginia in 2015. McCabe and his wife have maintained that some of Trump's accusations, especially about McCabe being ethically compromised by donations to her campaign, were false.

McCabe accuses Trump of threatening several top brass of the Justice Department -- from former Deputy Attorney General Rod Rosenstein, to inspector general Michael Horowitz, to then-attorney general Jeff Sessions -- as a way to "induce their compliance with Trump's desires," the lawsuit says.

Read More