Biden, 81, in a post on X, said he will remain in his role as president and commander-in-chief until his term ends in January 2025 and will address the public this week.
"It has been the greatest honour of my life to serve as your President. And while it has been my intention to seek re-election, I believe it is in the best interest of my party and the country for me to stand down and to focus solely on fulfilling my duties as President for the remainder of my term," Biden wrote.
His initial statement had not included an endorsement of Harris but he followed up a few minutes later with a post including an expression of support.
My fellow Democrats, I have decided not to accept the nomination and to focus all my energies on my duties as President for the remainder of my term. My very first decision as the party nominee in 2020 was to pick Kamala Harris as my Vice President. And it's been the best… — Joe Biden (@JoeBiden) pic.twitter.com/x8DnvuImJVJuly 21, 2024
His move could clear the way for Harris, 59, to run at the top of the ticket.
It was unclear whether other senior Democrats would challenge Harris for the party's nomination - she was widely seen as the pick for many party officials - or whether the party itself would choose to open the field for nominations.
Trump, the Republican candidate in the November 5 election, told CNN on Sunday that he believed Harris would be easier to defeat.
Biden had a change of heart on Sunday, a source familiar with the matter told Reuters.
The president told allies that as of Saturday night he planned to stay in the race before changing his mind on Sunday afternoon.
"Last night the message was proceed with everything, full speed ahead," a source familiar with the matter told Reuters, speaking on condition of anonymity.
"At around 1.45pm today: the president told his senior team that he had changed his mind."
Biden's announcement follows a wave of public and private pressure from Democratic lawmakers and party officials to quit the race after his poor performance in a June 27 televised debate last month against Republican rival Trump, 78.
— Joe Biden (@JoeBiden) pic.twitter.com/RMIRvlSOYwJuly 21, 2024
Days later he raised fresh concerns in an interview, shrugging off Democrats' worries and a widening gap in opinion polls, and saying he would be fine losing to Trump if he knew he'd "gave it my all".
His gaffes at a NATO summit - invoking Russian President Vladimir Putin's name when he meant Ukrainian President Volodymyr Zelenskiy and calling Harris "Vice President Trump" - further stoked anxieties.
Only four days before Sunday's announcement, Biden was diagnosed with COVID-19 for a third time, forcing him to cut short a campaign trip to Las Vegas.
Biden's historic move - the first sitting president to give up his party's nomination for re-election since President Lyndon Johnson in March 1968 - leaves his replacement with less than four months to wage a campaign.
Biden was the oldest US president ever elected when he beat Trump in 2020.
During that campaign, Biden described himself as a bridge to the next generation of Democratic leaders.
Some interpreted that to mean he would serve one term, a transitional figure who beat Trump and brought his party back to power.
But he set his sights on a second term in the belief that he was the only Democrat who could beat Trump again amid questions about Harris' experience and popularity.
His team had hoped a strong performance at the June 27 debate would ease concerns over his age.
But donors began to revolt and supporters of Harris began to coalesce around her.
Biden initially resisted pressure to step aside.
He held damage-control calls and meetings with lawmakers and state governors, and sat for rare television interviews.
But it was not enough.
Polls showed Trump's lead in key battleground states widening, and Democrats began to fear a wipe-out in the House and Senate.
On July 17, California's Representative Adam Schiff called on him to exit the race.
Biden's departure sets up a stark new contrast, between the Democrats' presumptive new nominee Harris, a former prosecutor, and Trump who at 78 is two decades her senior and faces two outstanding criminal prosecutions related to his attempts to overturn the 2020 election result.
He is due to be sentenced in New York in September on a conviction for trying to cover up a hush-money payment to a porn star.
Earlier this year, facing little opposition, Biden easily won the Democratic Party's primary race to pick its presidential candidate, despite voter concerns about his age.