WASHINGTON — Peter Strzok, the F.B.I. senior counterintelligence agent in the Hillary Clinton email and Russia investigations who made inflammatory comments about President Trump in text messages, sued the Justice Department and the F.B.I. on Tuesday for firing him.

The F.B.I. said last summer that it had terminated Mr. Strzok for violating bureau policies, but he said in his lawsuit that he was fired because of political pressure from Mr. Trump, who has made a frequent target of Mr. Strzok in his public statements.

“The F.B.I. fired Special Agent Strzok because of his protected political speech in violation of his rights under the First Amendment to the Constitution of the United States,” the lawsuit said. Mr. Strzok said his termination also violated his due process rights.

The Justice Department declined to comment, and the F.B.I. said it does not comment on pending litigation.