WASHINGTON — Deputy Attorney General Rod Rosenstein, who oversaw special counsel Robert Mueller's investigation, submitted his letter of resignation to President Donald Trump on Monday, ending his two years at the Department of Justice on May 11.

His resignation was expected; he had been saying for a long time that he planned to leave the department once Mueller's probe of Russian interference in the 2016 election, possible collusion by the Trump campaign and potential obstruction of justice by the president was completed.

"I am grateful to you for the opportunity to serve; for the courtesy and humor you often display in our personal conversations; and for the goals you set in your inaugural address: patriotism, unity, safety, education and prosperity," Rosenstein wrote in his resignation letter.

Rosenstein's successor, deputy transportation secretary Jeffrey Rosen, is awaiting Senate confirmation.

Rosenstein’s tenure as deputy attorney general was mired in controversy. From appointing Mueller as special counsel to the Justice Department's conclusion that Trump did not obstruct justice, Rosenstein drew criticisms from both sides of the aisle.

After Mueller didn't reach a conclusion on whether Trump had obstructed the investigation, Attorney General William Barr and Rosenstein stepped in and determined the evidence wasn't enough to support such an allegation.

Rosenstein appointed Mueller in May 2017 following the recusal of then-Attorney General Jeff Sessions and oversaw much of his work. His exit leaves the department without the official most closely aligned with the probe as officials grapple with public and congressional scrutiny of the special counsel's findings and the department's handling of the report.

He not only supervised Mueller's work for much of the last two years, but also defended the investigation against attacks from congressional Republicans and Trump, who has blasted it as a "witch hunt." In so doing, Rosenstein sometimes found himself at odds with Trump but was nonetheless spared the brunt of anger directed at Sessions, whose recusal infuriated the president, leading to Sessions' forced resignation last November.

After Trump fired FBI Director James Comey in the spring of 2017, Rosenstein discussed the possibility of removing Trump through the 25th Amendment in addition to wearing a wire during a future conversation with the president, according to former Deputy FBI Director Andrew McCabe. The New York Times first reported the discussion.

The Justice Department said McCabe's commentary on Rosenstein was false, which McCabe disputes. Rosenstein also disputed the Times' report on the discussion, calling it "inaccurate and factually incorrect."

Barr thanked Rosenstein for his service in a statement Monday, writing, "Over the course of his distinguished government career, he has navigated many challenging situations with strength, grace, and good humor. Rod has been an invaluable partner to me during my return to the Department, and I have relied heavily on his leadership and judgment over the past several months."

The deputy attorney general position is a hugely significant job, responsible for overseeing the daily operations of the Justice Department and the work of United States attorneys across the country.