Washington (CNN) President Donald Trump said Wednesday that Don McGahn will leave his job as White House counsel this fall following Supreme Court Justice nominee Brett Kavanaugh's confirmation.

"White House Counsel Don McGahn will be leaving his position in the fall, shortly after the confirmation (hopefully) of Judge Brett Kavanaugh to the United States Supreme Court. I have worked with Don for a long time and truly appreciate his service!" Trump tweeted.

McGahn's departure will close the book on a tumultuous relationship that has been both a boon for Trump's agenda and a test of the limits of Trump's executive authority. McGahn has been the key architect of Trump's successful efforts to reshape the federal courts -- sealing a lasting part of Trump's conservative legacy -- but he has also repeatedly clashed with the President over his attempts to interfere in the Justice Department's investigation of Russian interference and any collusion with the Trump campaign.

That strained relationship once again resurfaced earlier this month with the disclosure that McGahn has cooperated extensively with special counsel Robert Mueller's probe, participating in several interviews spanning 30 hours over the last nine months. The conversations unnerved Trump, who didn't know the full extent of McGahn's discussions, two people familiar with his thinking said.

Following the announcement of McGahn's departure, Trump told reporters Wednesday afternoon that McGahn is a "very good man."

"Been here now it'll be almost two years, and a lot of affection for Don," he said, adding that McGahn will "probably" be moving on to the private sector and that "he's done an excellent job."

Asked by CNN's Jim Acosta whether he was concerned about what McGahn said to special counsel Robert Mueller's team, Trump said, "No," adding that he "knew" McGahn was going to talk to Mueller.

"We didn't claim executive (privilege). We do everything straight. We do everything by the book and Don is an excellent guy," he said.

Trump's announcement comes as Mueller's investigation continues to consume much of the President's focus amid questions of potential obstruction of justice into the investigation of Russian interference in the 2016 election.

But McGahn's departure was anticipated before the disclosure of his extensive cooperation with Mueller's team. Earlier this month, sources close to the White House said McGahn was likely to leave his White House post after Kavanaugh's confirmation -- with McGahn hoping to first notch a second successful Supreme Court nomination.

Emmet Flood, who now directs the Russia legal strategy from inside the White House, is a potential replacement, CNN reported last week. McGahn fought to bring Flood onto the team and likes him very much, a source close to the White House said.

The plan to have Flood to replace McGahn as White House counsel has been in place since Flood arrived at the White House, a source familiar with the White House legal team told CNN. The source said McGahn's departure should surprise no one, adding that McGahn has not had a good relationship with the President for more than a year.

White House chief of staff John Kelly would bring McGahn into critical meetings with Trump just to keep him in the loop, the source said, adding that it was known inside the White House that McGahn threatened to resign at one point to keep the President from firing Mueller.

As for why Trump doesn't just fire McGahn, this source said it's typical, noting that the President "whines" about people but doesn't fire them, such as Attorney General Jeff Sessions.

The news of McGahn's eventual departure comes amid the advancement of Kavanaugh's confirmation hearing, which is set to start in less than a week and last three or four days, according to Senate Judiciary Chairman Chuck Grassley.

Tumultuous tenure in White House

JUST WATCHED Haberman talks McGahn and Trump relationship Replay More Videos ... MUST WATCH Haberman talks McGahn and Trump relationship 01:17

McGahn leaves his White House post after serving as White House counsel through the tumultuous first 18 months of Trump's presidency, steering the White House's handling of the Russia investigation and responding internally to the President's mercurial moods as the investigation ballooned.

His departure marks the latest of the handful of top aides who worked on the Trump campaign before joining the White House. McGahn served as the Trump campaign's top attorney throughout the GOP primary and 2016 presidential election, becoming a trusted adviser to the future president in the process.

He immediately faced controversy in his earliest days at the White House, beginning with acting Attorney General Sally Yates' warning to McGahn that then-national security adviser Michael Flynn could be blackmailed by Russia and that he had likely lied to Vice President Mike Pence. Flynn was forced to resign after reports revealed Yates' warning to McGahn about Flynn's conduct.

As the Justice Department and congressional investigations into Russian meddling in the 2016 election heated up, McGahn found himself increasingly at the center of Trump's and the White House's response to the investigation.

And when Attorney General Jeff Sessions faced pressure to recuse himself, Trump enlisted McGahn to urge Sessions not to take that step. Se ssions eventually did recuse himself, giving his deputy, Rod Rosenstein, the ultimate authority to appoint a special counsel.

But for McGahn, the President's order to fire Mueller was a bridge too far -- with the White House counsel refusing to follow through on the order, a person familiar with the matter told CNN. The New York Times first reported Trump's move to fire Mueller and McGahn's refusal to carry out the order.

The slew of incidents involving the President and McGahn amid the Russia investigation made the White House counsel an important witness in Mueller's investigation.

Before joining the Trump campaign and the White House, McGahn worked at the powerful DC law firm Jones Day and previously served as a commissioner on the Federal Election Commission.

McGahn also earned the trust and respect of key Republicans on Capitol Hill.

As the latest reports about McGahn's likely departure emerged Wednesday morning, Grassley, the Judiciary Committee chairman, tweeted to the President.

"I hope it's not true McGahn is leaving WhiteHouse (sic) Counsel. U can't let that happen," he tweeted at Trump.

But he was too late. Twenty-three minutes earlier, Trump had tweeted the announcement of McGahn's planned exit.