WASHINGTON — The special counsel, Robert S. Mueller III, removed a top F.B.I. agent this summer from his investigation into Russian election meddling after the Justice Department’s inspector general began examining whether the agent had sent text messages that expressed anti-Trump political views, according to three people briefed on the matter.

The agent, Peter Strzok, is considered one of the most experienced and trusted F.B.I. counterintelligence investigators. He helped lead the investigation into whether Hillary Clinton had mishandled classified information on her private email account, and then played a major role in the investigation into links between President Trump’s campaign and Russia.

But Mr. Strzok was reassigned this summer from Mr. Mueller’s investigation to the F.B.I.’s human resources department, where he has been stationed since. The people briefed on the case said the transfer followed the discovery of text messages in which Mr. Strzok and a colleague reacted to news events, like presidential debates, in ways that could appear critical of Mr. Trump.

“Immediately upon learning of the allegations, the special counsel’s office removed Peter Strzok from the investigation,” said a spokesman for the special counsel’s office, Peter Carr.