A top FBI agent at the center of both the Clinton email and Trump-Russia investigations was removed from Special Counsel Robert Mueller’s team for exchanging derogatory text messages about the president with a colleague.

Peter Strzok, a veteran FBI investigator, was shuffled off to the FBI’s human resources department by Mueller after the Justice Department’s inspector general opened an investigation into the texts, The New York Times reported on Saturday.

And according to The Washington Post, Strzok exchanged the messages with Lisa Page, an FBI lawyer who was also assigned to and later removed from Mueller’s team. Strzok and Page, who works for FBI deputy director Andrew McCabe, were reportedly having an extramarital affair.

Peter Carr, a spokesman for Mueller’s office, said that Strzok was removed from the Russia investigation as soon as the inspector general’s findings were revealed this summer.

“Immediately upon learning of the allegations, the Special Counsel’s Office removed Peter Strzok from the investigation. Lisa Page completed her brief detail and had returned to the FBI weeks before our office was aware of the allegations,” Carr told The Daily Caller.

The text messages showed Strzok and Page reacting with anti-Trump sentiments to certain news events, including the presidential debates.

Mueller’s personnel moves, which were made at some point over the summer, had remained a mystery of the former FBI director’s expansive investigation. (RELATED: In Odd Move, Mueller Removes One Of His Trump-Russia Investigators)

Strzok was a major player in the Clinton email and Trump-Russia investigations.

He was the FBI’s lead investigator on the Clinton email investigation, so much so that he interviewed the former secretary of state on July 2, 2016.

Days later, then-FBI Director James Comey announced that he would not be recommending charges against Clinton for mishandling classified information on her private email server.

WATCH US INTELLIGENCE OFFICIALS DISCUSS TRUMP-RUSSIA CONNECTIONS:

The New York Times identified Strzok earlier this year as the agent tapped by FBI brass to supervise the investigation into possible collusion between the Trump campaign and Russia.

As The Times reported in April:

In late July [2016], the F.B.I. opened an investigation into possible collusion between members of Mr. Trump’s campaign and Russian operatives. Besides Mr. Comey and a small team of agents, officials said, only a dozen or so people at the F.B.I. knew about the investigation. Mr. Strzok, just days removed from the Clinton case, was selected to supervise it.

The Times also reported that Strzok relied on information provided to the FBI by Christopher Steele, the former British spy who was hired by an opposition research firm working for the Clinton campaign to investigate Trump’s Russia activities.

Steele briefed FBI agents in early July 2016 on some of the rumors he had heard about Trump. In a dossier he started working on in June 2016, Steele alleged that the Kremlin had blackmail material on Trump and that the Trump campaign was working directly with Russian government officials to influence the election.

“It took weeks for this information to land with Mr. Strzok and his team,” The Times reported in April.

Carr, the spokesman for Mueller, declined to comment on other aspects of the Strzok story, including why it took so many months to find out why he was kicked off of the Russia probe.

This article has been updated with comment from the Special Counsel’s office.

Follow Chuck on Twitter