Barr will leave office within days, weeks after he angered Trump by contradicting his claims of having been the victim of mass fraud in the November presidential election.
"Bill will be leaving just before Christmas to spend the holidays with his family," Trump tweeted.
Barr, Trump's second attorney general, was heavily criticized by Democrats for what they said was his unethical behavior to shield Trump during a probe by special counsel Robert Mueller into the president's Russia connections.
"Good riddance to the worst most corrupt despicable Attorney General in US history," House Democrat Bill Pascrell tweeted.
"William Barr was willing to do the President’s bidding on every front but one. Barr refused to play along with President Trump’s nonsensical claims to have won the election," Democratic House of Representatives Judiciary Committee Chairman Jerrold Nadler said.
Trump was deeply angered after he failed, in the eyes of the president, to use the Justice Department to help the US president’s campaign or to back up Trump's claims that Biden only won because of vote fraud.
When Barr made clear that nothing of the sort was forthcoming, Trump fumed publicly that he would be "very disappointed."
Barr had said after the vote that "we have not seen fraud on a scale that could have effected a different outcome in the election" -- an assessment that put a gaping hole in Trump's still ongoing disinformation campaign.
Trump's legal team accused Barr of failing to conduct a proper inquiry into the allegations of voting fraud.