Mr Trump had criticized his top law official for months, mainly over his refusal to oversee the investigation into alleged Russian meddling in favour of Mr Trump’s election in 2016.
Mr Sessions’s chief of staff, Matthew Whitaker, who has criticized the inquiry, will take over temporarily.
Special Counsel Robert Mueller is investigating alleged collusion between the Trump campaign and Russia.
Mr Mueller’s wide-ranging investigation has resulted in a series of criminal charges against several Trump associates.
In a resignation letter, Mr Sessions – a former Alabama senator who was an early supporter of Mr Trump – made clear the decision to go was not his own.
“Dear Mr President, at your request I am submitting my resignation,” he wrote in an undated letter.
Most importantly, in my time as attorney general, we have restored and upheld the rule of law,” Mr Sessions added, while thanking the Republican president.
“We thank Attorney General Jeff Sessions for his service, and wish him well!” Mr Trump tweeted on Wednesday.
Given his previous comments advocating defunding and imposing limitations on the Mueller investigation, Mr Whitaker should recuse himself from its oversight for the duration of his time as acting attorney general.”
Why was Sessions fired?
Mr Trump has repeatedly pilloried his top law enforcement official since Mr Sessions stepped aside from the Russia inquiry in March 2017.
In July 2017 Mr Trump told the New York Times: “Sessions should have never recused himself, and if he was going to recuse himself, he should have told me before he took the job and I would have picked somebody else.”
Mr Sessions voluntarily removed himself from the probe after Democrats accused him of failing to disclose contacts with the Russian ambassador during his Senate confirmation hearing.
The attorney general later said he had forgotten about those meetings, which happened during the Trump election campaign.
Mr Trump has at various times belittled Mr Sessions as “VERY weak” and “DISGRACEFUL”.