Peter Strzok, the senior FBI official who helped lead the initial probe of ties between Russia and the Trump campaign until it was discovered he sent anti-Trump texts, was fired from the agency on Monday, NBC News has confirmed.

Strzok, a 21-year veteran of the department, had exchanged text messages criticizing President Donald Trump with FBI lawyer Lisa Page, with whom he had an affair, during the 2016 presidential campaign. Both worked on the Hillary Clinton email investigation and also on special counsel Robert Mueller's probe of possible collusion between the Trump campaign and Russia.

Aitan Goelman, Strzok’s attorney, confirmed to NBC News that the firing happened late Friday afternoon and was ordered by David Bowdich, the deputy director of the FBI.

"The decision to fire Special Agent Strzok is not only a departure from typical Bureau practice, but also contradicts Director Wray’s testimony to Congress and his assurances that the FBI intended to follow its regular process in this and all personnel matters," he said.

"This decision should be deeply troubling to all Americans. A lengthy investigation and multiple rounds of Congressional testimony failed to produce a shred of evidence that Special Agent Strzok’s personal views ever affected his work."

He added, "The FBI and the American people deserve better."

Trump celebrated the news of Strzok's firing on Twitter, calling the probe into Russian election interference a "total Hoax."

"Agent Peter Strzok was just fired from the FBI — finally. The list of bad players in the FBI & DOJ gets longer & longer. Based on the fact that Strzok was in charge of the Witch Hunt, will it be dropped? It is a total Hoax. No Collusion, No Obstruction — I just fight back!" he said.

Agent Peter Strzok was just fired from the FBI - finally. The list of bad players in the FBI & DOJ gets longer & longer. Based on the fact that Strzok was in charge of the Witch Hunt, will it be dropped? It is a total Hoax. No Collusion, No Obstruction - I just fight back! — Donald J. Trump (@realDonaldTrump) August 13, 2018

He also suggested in a later tweet that the FBI should re-open its investigation into Clinton's use of a private email server while serving as secretary of state, since Strzok helped to oversee it.

"Just fired Agent Strzok, formerly of the FBI, was in charge of the Crooked Hillary Clinton sham investigation. It was a total fraud on the American public and should be properly redone!" Trump said.

Just fired Agent Strzok, formerly of the FBI, was in charge of the Crooked Hillary Clinton sham investigation. It was a total fraud on the American public and should be properly redone! — Donald J. Trump (@realDonaldTrump) August 13, 2018

The FBI — after closing the case in July 2016, re-opening it in October 2016, and then closing it again just days before the election — recommended no charges be brought against Clinton. The agency's internal watchdog later rebuked then-FBI Director James Comey for his handling of the probe, including his decision to go public with the re-opening of the investigation so close to Election Day.

In August 2016, within one week of the Justice Department's decision to open the Russia probe, Strzok sent messages to Page that said "F Trump" and "I can protect our country at so many levels."

That same year, Strzok told Page on July 14, "It's clear he's capturing all the white, poor voters who the mainstream Republicans abandoned in all but name in the quest for the almighty $$$$."

In other messages, the pair shared pro-Clinton views. Strzok told Page in March, "God Hillary should win 100,000,000-0."

Strzok then praised Clinton's nomination in July: "Congrats on a woman nominated for President in a major party! About damn time!"

The messages were sent from Aug. 16, 2015 to Dec. 1, 2016. When Mueller learned of the exchanges last summer, he removed Strzok from the special counsel team.

Many of the texts were sent before Trump and Clinton secured their respective party's nomination. Strzok and Page also took shots at other candidates in the race, including former Maryland Gov. Martin O'Malley, Vermont Sen. Bernie Sanders — both of whom were seeking the Democratic nomination — and Ohio Gov. John Kasich, a Republican.

"I just saw my first Bernie Sanders bumper sticker. Made me want to key the car," Page wrote.

Strzok responded: "He's an idiot like Trump. Figure they cancel each other out."

Goelman, Strzok's attorney, said the firing went against established protocol and that Bowdich had overruled the FBI's Office of Professional Responsibility.

"In doing so he reversed the decision of the career FBI official responsible for employee discipline who concluded, through an independent review process, that a 60-day suspension and demotion from supervisory duties was the appropriate punishment," Goelman said in his statement on Monday.

Trump and his supporters have repeatedly held up the text messages between Strzok and Page as evidence of bias against him within the law enforcement agency.

House Majority Leader Kevin McCarthy, R-Calif., tweeted Monday that Strzok's firing was "long overdue."

Strzok defended himself against claims that the personal political views he shared with Page affected his official conduct during his testimony before a joint hearing of the House Oversight and Judiciary Committees in July.

“To suggest somehow we can parse down the words of shorthand textual conversations like they're some contract for a car is simply not consistent with my or most people's use of text messaging,” he said. “The suggestion that I in some dark chamber somewhere in the FBI would somehow cast aside all of these procedures, all of these safeguards, and somehow be able to do this is astounding me. It simply couldn’t happen. And the proposition that it is going on, that it might occur anyway in the FBI, deeply corrodes what the FBI is in American society.”