The special counsel, Robert S. Mueller III, removed a top F.B.I. agent from his investigation into Russian election meddling after the Justice Department’s inspector general began examining whether the agent 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 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.