Peter Strzok has been accused by Republicans of being biased against Donald Trump, and seeking to prevent his election victory.
Mr Trump has pointed to the text exchanges as evidence of bias in the special counsel's Russia probe.
Mr Strzok served on the Russia probe and the Hillary Clinton email inquiry.
Mr Strzok's lawyer Aitan Goelman said in a statement that FBI Deputy Director David Bowdich ordered the firing on Friday.
He said the sacking overruled a decision by the head of FBI employee discipline, who determined that Mr Strzok should only face a demotion and a 60-day suspension.
"The decision to fire Special Agent Strzok is not only a departure from typical Bureau practice, but also contradicts Director [Christopher] Wray's testimony to Congress and his assurances that the FBI intended to follow its regular process in this and all personnel matters," Mr Goelman said in a statement on Monday.
"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."
A spokesperson for the FBI told the BBC that they could not immediately comment on Mr Strzok's firing.
Mr Trump took to Twitter on Monday to ask when the inquiry into Russia's alleged meddling in the 2016 election, which is being led by ex-FBI director Robert Mueller, will end.
"Agent Peter Strzok was just fired from the FBI - finally. The list of bad players in the FBI & DOJ gets longer & longer," he tweeted.
In another tweet, he called the inquiry into Hillary Clinton's email server, a "sham investigation," saying it "was a total fraud on the American public and should be properly redone!"
During the election, Mrs Clinton was investigated by the FBI over her use of a private email server to handle sensitive government documents during her time as secretary of state.
What did the texts say?
Mr Strzok exchanged text messages that disparaged Mr Trump with FBI lawyer Lisa Page, with whom he was having an affair.
In one exchange, Ms Page asks: Trump is "not ever going to become president, right? Right?!"
Mr Strzok responds: "No. No he won't. We'll stop it."
Mr Trump has attacked the two "FBI lovers" as recently as last Saturday.
"So many of the great men and women of the FBI have been hurt by these clowns and losers!"
What has Mr Strzok said?
In a heated congressional hearing last month, Mr Strzok - a 21-year veteran of the FBI - asserted there was "no evidence of bias in my professional actions".
He was repeatedly attacked by Republican lawmakers, and expressed "significant regret" for the texts.
Under FBI regulations, agents may express political opinions "as an individual". It is not clear whether these texts were sent from work phones.
Amid Republican criticism last year, Deputy Attorney General Rod Rosenstein said he was confident the special counsel team was being run "appropriately".
Republicans: FBI Trump texts show bias
Mr Rosenstein also noted that the FBI had rules against checking a person's politics during the hiring process.
"We are not going to improperly consider political affiliation with our career employees," he said.
Mr Strzok is the third high-profile FBI employee who had been involved in the Russia and Clinton investigations to be fired since Mr Trump took office.
FBI Director James Comey was fired by Mr Trump, who later said he had been thinking of the Russia inquiry when he made his decision.
His deputy Andrew McCabe was removed by Attorney General Jeff Sessions after an inspector general determined that he had made unauthorised leaks to the press about the Clinton investigation.
More about: FBI