Former FBI special agent Peter Strzok is suing the FBI and Justice Department, claiming his firing in 2018 violated his rights to due process and free speech and was only carried out because of political pressure.

Strzok, who worked on former special counsel Robert Mueller's team for a time, has become a frequent target of President Trump after he wrote text messages extremely critical of Mr. Trump when he was a candidate. Strzok, who filed the suit in the U.S. District Court for the District of Columbia, is trying to get his job with the FBI back.

One of Strzok's attorneys, Aitan Goelman, a partner with Zuckerman Spaeder LLP, blamed the firing on Mr. Trump's rhetoric.

Get Breaking News Delivered to Your Inbox

"While many in law enforcement have faced attacks by this president, Pete Strzok has been a constant target for two years. It's indisputable that his termination was a result of President Trump's unrelenting retaliatory campaign of false information, attacks and direct appeals to top officials," Goelman said in a statement.

Strzok was removed from the Mueller probe after the messages were discovered, and moved to a different office still within the FBI. Strzok was heavily criticized last year in a blistering June 2018 Justice Department Inspector General report, and was escorted from the building later that summer.

Strzok became the face of everything Mr. Trump and his allies viewed as problematic with the FBI, after the revelation that he and then-fellow FBI official Lisa Page exchanged anti-Trump text messages. Strzok worked on the Hillary Clinton email investigation, and then special counsel Robert Mueller's probe into Russian election meddling and any ties to Trump associates.

During congressional testimony last summer, Strzok said he was "deeply regretful" of sending the anti-Trump texts to his colleague, but said he did so with the expectation of privacy.

"I had no idea that this was going to happen," he said at the time.