WASHINGTON — The F.B.I.’s embattled deputy director, Andrew G. McCabe, an unlikely lightning rod who has been attacked repeatedly by President Trump and congressional Republicans, is expected to retire after he becomes eligible for his pension early next year, according to people familiar with his decision.

While Mr. McCabe’s plans to leave aren’t unexpected, his decision should take some of the pressure off Christopher A. Wray, who was confirmed as F.B.I. director in August. Mr. Trump has complained to confidantes that Mr. Wray has not moved fast enough to replace the senior leadership that he inherited from his predecessor, James B. Comey, whom Mr. Trump summarily dismissed in May.

A White House official said in a statement this week that many senior leaders of the bureau were “politically motivated” and said Mr. Wray was the “right choice to clean up the misconduct at the highest levels of the F.B.I.”