Andrew G. McCabe, the former F.B.I. deputy director who was fired for statements he made about communications between the bureau and the press, sued the F.B.I. and the Justice Department on Thursday, alleging that the dismissal was retaliatory and politically motivated.

The Justice Department engaged in a “politically motivated and retaliatory demotion in January 2018 and public firing in March 2018,” Mr. McCabe said in his lawsuit.

He added that President Trump “purposefully and intentionally” pushed the Justice Department to demote and terminate him as part of an “unconstitutional plan” to discredit and remove Justice Department and F.B.I. employees who were “deemed to be his partisan opponents.”

Mr. McCabe, 51, was also the subject of a scathing Justice Department inspector general report that accused him of violating the bureau’s media policy when he authorized the disclosure of information to the press and of misleading investigators about what he had done.

When he was fired, Mr. McCabe told The New York Times that he had been let go for political reasons. He was among the first F.B.I. officials to ask whether the Trump campaign had questionable ties to Russia and whether Mr. Trump himself had tried to obstruct justice.

“The idea that I was dishonest is just wrong,” he told The Times. “This is part of an effort to discredit me as a witness.” […]