Deputy Attorney General Rod Rosenstein is expected to leave his role in the coming weeks, multiple sources familiar with his plans told ABC News.

Rosenstein has communicated to President Donald Trump and White House officials his plan to depart the administration around the time William Barr, Trump's nominee for attorney general, would take office following a Senate confirmation.

Sources told ABC News Rosenstein wants to ensure a smooth transition to his successor and would accommodate the needs of Barr, should he be confirmed.

Rosenstein apparently had long been thinking he would serve about two years, and there was no indication that he was being forced out at this moment by the president.

Upon the termination of Attorney General Jeff Sessions, speculation mounted that Rosenstein would depart shortly thereafter, yet he's remained in his post as Matt Whitaker has served as acting Attorney General since late November.

Win McNamee/Getty Images, FILE

Rosenstein oversaw special counsel Robert Mueller's probe for more than a year, after Sessions had recused from the matter over his role in Trump's presidential campaign.

Like other senior leaders within the Justice Department, Rosenstein became a frequent target of Trump's on Twitter, with the president recently re-posting an image of Rosenstein and others behind bars.

In May 2017, shortly after Trump fired James Comey as FBI Director, Rosenstein made the call to appoint Mueller to take over the FBI probe of Russia's meddling in the 2016 presidential election and any possible ties between Russian operatives and Trump associates.

Trump and his Republican allies have repeatedly blasted that decision. But tensions between Trump and Rosenstein came to a head in September, after reports surfaced saying that, during a meeting in the immediate aftermath of Comey's firing, Rosenstein raised the possibility of secretly recording the president at the White House.

However, a source familiar with how Justice Department officials who attended that later meeting viewed what happened, said they believed Rosenstein was being "sarcastic" -- noting that there was never any follow-up conversation from Rosenstein or anyone else about it.

Jim Watson/AFP/Getty Images, FILE

Speaking later about the reports, Rosenstein never totally disputed making such a remark, but he insisted the reports were overblown and that he never took any action to secretly record Trump. A private conversation between Trump and Rosenstein weeks later seemed to cool tensions.

Rosenstein played a significant role in Comey's constroversial firing. He and Sessions each submitted letters to Trump, laying out why they believed Comey's termination was warranted. In particular, Rosenstein took Comey to task for his handling of the FBI's investigation of Hillary Clinton's use of a personal email server, and the White House repeatedly pointed to Rosenstein's letter to defend removing Comey.

Though Rosenstein became deputy attorney general under Trump, he served in senior Justice Department roles under both Republican and Democratic presidents. Many of his colleagues within the Justice Department view him as someone who's made decisions based on protecting the department's legacy.

File-Jim Watson/AFP/Getty Images

With questions mounting over Trump's appointment of Whitaker to replace Sessions as acting attorney general, Rosenstein walked to cameras to publicly praise Whitaker, fearing more public concern over the Justice Department could do lasting damage to the institution, sources told ABC News.

Whitaker had been critical of the Mueller probe in media appearances from before joining the Trump Justice Department, which raised questions about his impartiality in overseeing the probe.

From 2005 to 2017, Rosenstein served as U.S. attorney for the District of Maryland. Over 15 years before that, he served in senior roles throughout the Justice Department, prosecuting public corruption and other federal crimes, and serving as a senior counselor in the department during the Clinton administration.

During his March 2017 confirmation hearing to become deputy attorney general, Rosenstein told Senators he would "certainly" resign his post if he felt he was being inappropriately pressured to influence an investigation.