Mr Barr, one of Mr Trump’s staunchest allies, went to the White House on Monday, where the president said he submitted his letter of resignation.
“As per letter, Bill will be leaving just before Christmas to spend the holidays with his family,” Mr Trump tweeted.
Mr Trump also vented his rage after that the Justice Department did not publicly announce it was investigating Hunter Biden ahead of the election, despite department policy against such a pronouncement.
The president said deputy attorney general Jeff Rosen, whom he labelled “an outstanding person”, will become acting attorney general.
The voting milestone came late on Monday as California electors affirmed the Democrat’s massive five million vote win last month in the nation’s largest state.
The Electoral College took on added importance this year because of Mr Trump’s refusal to concede he lost his race for re-election.