Joe Biden's senior White House and campaign staff had spent the past week insisting the president planned to stay in the 2024 race despite an onslaught of calls within the Democratic Party for him to step aside.
As recently as Saturday, the president's aides were putting together a campaign schedule for him to pick up upon his return to the White House next week. He had been recovering from Covid at his beach house on the eastern shores of Delaware, insisting that he was still running but infuriated as a co-ordinated effort to pressure him to exit by some Democrats began to spill into public view.
By Sunday morning, the president had changed his mind, according to sources who were granted anonymity to speak candidly about how the day unfolded.
On Saturday evening, Mr Biden began to consider whether he should withdraw, one of the toughest decisions of his 50-year political career. He huddled with a small circle of aides, which included Steve Richetti, one of his closest advisers, Mike Donilon, his chief strategist, Annie Tomasini, his deputy chief of staff and Anthony Bernal, the chief of staff to First Lady Jill Biden.
Mr Richetti, who has been a close aide of the president's since his Senate days, drove out to the president's beach house on Friday. Mr Donilon, another aide who has played a key role in some of the president's biggest political decisions, joined on Saturday. Mr Biden and his aides pored over new polling data and discussed whether he could defeat Donald Trump in the current political landscape.
Faced with the new data and bracing for another week of more public defections within the party, the president had a decision to make. He worked with Mr Donilon, drafting the historic statement that would bring an end to candidacy while Mr Richetti worked through the details of rolling out the announcement and informing other staff.
Biden made the final decision that he was dropping out on Sunday morning, separately calling chief of staff Jeff Zients, his campaign chair Jen O'Malley Dillon and Vice-President Kamala Harris to inform them, sources familiar with how the events of Sunday unfolded told the BBC.
On Sunday afternoon at 13:45 EDT (17:45 GMT), the president held a video call with his most senior White House and campaign staff, including Anita Dunn, who manages his White House communications strategy. One minute later, he released a public statement that sent shockwaves across the American political landscape and upended the 2024 election.
"He said he had been reflecting on it over the past couple of days," a senior White House official told the BBC. "It was a closely-held decision."
Though Mr Biden did not mention Ms Harris in his initial statement, he tweeted his endorsem*nt for his vice-president about half an hour later. The two spoke multiple times throughout the day in the lead-up to the stunning announcement, according to two sources familiar with the conversations.
The first lady, who is the president's closest adviser and someone whose counsel is considered to have been one of the deciding factors in his decision, said in a statement that she was supportive of his exit.
"Down to the last hours of the decision only he could make, she was supportive of whatever road he chose," Elizabeth Alexander, the first lady's communications director, said of Mrs Biden. "She's his biggest believer, champion and always on his side, in that trusted way only a spouse of almost 50 years can be."
Many in the White House and on the campaign were not informed of Mr Biden's plans in advance. Most found out from the post on social media.
Mr Zients, the president's chief-of-staff, held a call with White House officials and emailed the wider West Wing staff to confirm the announcement and thank them for their hard work. He also led a call with the president's cabinet secretaries.
Mr Biden, meanwhile, spoke to several congressional Democrats, governors and supporters, according to a White House statement. He planned to continue making calls on Sunday night and on Monday, the statement said.
Kamala Harris, who said she planned to "earn and win" the presidential nomination, spent Sunday afternoon calling lawmakers - including House Minority Leader Hakeem Jeffries - key party officials and governors to shore up support for her candidacy.
Though she's already earned the support of the president and top Democrats, her ascension to the top of the ticket is not certain until delegates vote to confirm Mr Biden's replacement at the Democratic National Convention in August.
Notably, former president Barack Obama has not explicitly endorsed her, while BIll and Hillary Clinton have.
During a campaign call on Sunday afternoon, as many were still digesting the news, top officials said the team would be "full steam ahead" behind the vice-president.
"All of you, all of us, wherever we come from, are here for Joe Biden and Kamala Harris and to defeat Donald Trump. And while today is a big day of transition, nothing changes with why you got here and what we're all here to do," said Jen O'Malley Dillon, the campaign chair, according to a source familiar with the call.
"But the path forward is a path that is for all of us to do this together."
Do you have any questions? We will be answering a selection of them.
LIVE: Latest updates as Joe Biden drops out of US presidential election race
WATCH: How Joe Biden's bid for re-election came to an end
IN FULL: Biden's letter announcing his withdrawal
PROFILE: Kamala Harris, the VP who Biden is backing for president
ANALYSIS: What Biden quitting means for Harris, the Democrats and Trump