WASHINGTON — A veteran FBI counterintelligence agent was removed from special counsel Robert Mueller’s team investigating Russian election meddling after the discovery of an exchange of anti-Trump text messages, a person familiar with the matter said Saturday.

The removal of the agent, who also had worked on the investigation of Hillary Clinton’s use of a private email server, occurred this summer. The person spoke on condition of anonymity.

Meanwhile, Peter Carr, a spokesman for Mueller, said Mueller removed the agent, Peter Strzok, from the team “immediately upon learning of the allegations.”

The removal undoubtedly reflected a desire to insulate the investigators from any claims of political bias or favoritism. President Donald Trump and many of his supporters have sought to discredit the investigation, in part by claiming a close relationship between Mueller and fired FBI Director James Comey and by pointing to political contributions to Democratic candidates made by some lawyers on the team.

The existence of the text messages was brought to the attention of Mueller’s office by the inspector general’s office, which has been conducting a wide-ranging investigation of the FBI’s handling of the Clinton email case.

Mueller has been investigating whether Trump campaign associates coordinated with Russia to influence the outcome of the 2016 presidential election, and Strzok’s background in counterintelligence would have been seen as particularly valuable for a secretive FBI probe examining foreign contacts.

Four people have been charged as a result of Mueller’s investigation. The most recent charge occurred Friday when former national security adviser Michael Flynn pleaded guilty to lying to the FBI about his conversations with the Russian ambassador. He has agreed to cooperate with the investigation.

The nature of the messages Strzok exchanged and with whom he communicated was not immediately clear. In his statement, Carr noted that an FBI lawyer, Lisa Page, had briefly been detailed to the team but left “before our office was aware of the allegations.”

Phone numbers for Strzok and Page could not immediately be found, and the FBI declined comment.

The New York Times first reported the agent’s removal.

Strzok was present during Clinton’s July 2016 interview with the FBI about her use of a private email server while she was secretary of state, according to an unclassified summary of the interview. Several other FBI agents and officials from the Justice Department also attended. The investigation was concluded without criminal charges days later.