FBI Director Christopher Wray is sworn in before a House Judiciary Committee hearing on Capitol Hill on Dec. 7, 2017. (Aaron P. Bernstein/Reuters)

The FBI’s top lawyer, James Baker, is being reassigned — one of the first moves by new director Christopher A. Wray to assemble his own team of senior advisers as he tries to fend off accusations of politicization within the bureau.

Baker told colleagues he will be taking on other duties at the FBI, according to people familiar with the matter. In recent months, Baker had been caught up in a strange interagency dispute that led to a leak probe and attracted the attention of senior lawmakers, but people familiar with the matter said the probe had recently ended with a decision not to charge anyone. The leak issue had not played a part in Baker’s reassignment, these people said.

Baker, one of the most trusted, longest-serving national security officials in the government, has served as the head of the FBI’s Office of General Counsel for several years, playing a key role in the agency’s handling of major cases and policy debates, including the FBI’s unsuccessful battle with Apple over the growing use of encryption in cellphones.

Baker informed colleagues in an email Wednesday that his duties were changing at the FBI, according to people familiar with the matter. Two said he is being “reassigned’’ by Wray, but they cautioned that the change does not take effect immediately and such a move is a normal part of a new director taking charge at the bureau — not a reflection of the political controversies buffeting the FBI.

In recent days, conservatives have intensified their calls for a housecleaning at the senior levels of the FBI. Since Wray became director in August, Baker has told colleagues he expected the new boss would eventually pick someone else for his position.

He was close to former FBI director James B. Comey, who asked Baker to be his general counsel. They were colleagues at the Justice Department and when they were out of government, at the investment management firm Bridgewater Associates.

Baker declined to comment, as did an FBI spokesman.

For months, Baker had become caught up in what some law enforcement officials considered a particularly frustrating probe of a leak involving the FBI, the National Security Agency and stories that appeared about a year ago involving surveillance techniques for a particular email provider, according to people familiar with the matter.

Some NSA officials were concerned that too much had been revealed about a classified program in an effort to correct a prior report, these people said.

“Jim was distressed about it but was confident he hadn’t leaked anything’’ and would be cleared, one U.S. official said.

A respected veteran prosecutor was assigned to the case, but people close to the matter said the investigation had petered out recently and charges were not expected to be filed.

The leak probe frustrated some in law enforcement, who said officials were caught up in it only because they had tried to prevent misinformation about surveillance capabilities from spreading among the public and lawmakers. Others said the very existence of the investigation was mostly due to a disagreement between two agencies, according to people familiar with the matter.

Since taking office, President Trump has repeatedly demanded that the Justice Department and FBI more aggressively pursue leak investigations, and congressional Republicans have echoed much of that criticism. Last week, House Judiciary Committee Chairman Bob Goodlatte (R-Va.) singled out Baker, noting he was the subject of a leak investigation, though by that time, the probe was effectively over.