Large sums scooped up by Democrats in the final months of 2019 are solidifying a top tier of candidates heading into the early presidential voting season, with multiple contenders showing signs of strength in the battle for the party’s nomination.

At the same time, President Trump brought in his biggest haul ever last quarter, as his impeachment by the Democratic-controlled House energized his base and produced an outpouring of $46 million. Trump’s reelection campaign barreled into the new year with more than $100 million to spend.

In all, the Democratic presidential candidates together raised at least $118 million in the last quarter — a sum that party strategists said points to the mounting energy and financial resources that will coalesce around the eventual nominee. Still, the figures underscored the unsettled nature of the Democratic primary fight, while highlighting Trump’s success in stockpiling tens of millions of dollars for his campaign and the Republican Party.

The Democratic pack was led by Sen. Bernie Sanders (I-Vt.), who pulled in an eye-popping haul of $34.5 million while expanding his donor base by hundreds of thousands of supporters — marking a remarkable political revival for a candidate whose heart attack in October prompted questions about the future of his candidacy.

Pete Buttigieg, who has catapulted from the little-known mayor of South Bend, Ind., to a national name, drew $24.7 million, demonstrating his ability to compete financially.

Former vice president Joe Biden raised $22.7 million, topping his previous quarter by $7 million, a sign of his resilience heading into the primary season.

Sen. Elizabeth Warren (D-Mass.) had not yet released her fundraising totals for the last quarter of 2019 but was expected to post a strong number, as well. Her campaign has said she raised at least $17 million, with a goal of surpassing $20 million.

Party strategists said that the large sums pulled in by multiple candidates were a sign of strength.

“The Democratic online money machine is alive and well,” said Jim Messina, who was campaign manager for President Barack Obama, adding that “the major players will all have enough money to make their cases in Iowa and be able to go back to supporters if they are still alive.”

Meanwhile, Trump’s campaign credited the impeachment process with filling the president’s campaign coffers, arguing that Republican voters have been energized as never before.

“This lit up our base,” Trump campaign manager Brad Parscale told reporters last month.

On Thursday, the Democratic field continued to narrow. Julián Castro, the former mayor of San Antonio who served as housing secretary under Obama, dropped out of the race after failing to qualify for the past two debates. A senior adviser to self-help author Marianne Williamson confirmed that she had laid off all her campaign staff at the end of December, though she has not yet officially suspended her campaign.

The candidates are announcing key numbers in advance of the Jan. 31 deadline to file information about their fundraising, spending and cash on hand — details that will emerge days before the first caucuses in Iowa.

Businessman Andrew Yang, a political novice, raised $16.5 million in the fourth quarter, a big improvement thanks to the “Yang Gang,” his online grass-roots followers drawn to his outsider candidacy. Rep. Tulsi Gabbard (D-Hawaii) said she raised $3.4 million.

Meanwhile, Buttigieg and Biden have benefited from the departure of Sen. Kamala D. Harris (D-Calif.), picking up high-profile wealthy supporters who backed her candidacy, according to donors and fundraisers.

But Sanders’s fundraising — up nearly $12 million from the third quarter — showed the clearest sign of momentum in the money race and the passion of his online donor base.

His grass-roots operation even drew an acknowledgment from some of the president’s backers. “Bernie’s cash is real,” said Bryan Lanza, who advised Trump’s 2016 campaign and transition efforts.

Sanders has experienced a resurgence over the past three months after stagnating in the summer and early fall. His lowest point came Oct. 1, when he suffered a heart attack that sidelined him from the race.

He has rebounded with a strategy that has diverged sharply from most of his rivals’. As others have fled to the center the past few months, Sanders has been content to stay firmly entrenched on the party’s left flank and is beginning to dominate that space.

He routinely touts his signature proposal — swiftly enacting a Medicare-for-all system in which the government provides all health insurance — at a moment when Warren and others have adopted more-gradual and less sweeping changes to current law than they once advocated.

With four weeks left until voting begins in Iowa, Sanders is focusing heavily there, a state his advisers see as crucial to his chances of winning the nomination. They are hoping for a victory — or at least a top-tier finish, preferably ahead of Warren and Biden.

After he nearly toppled Hillary Clinton in Iowa four years ago, polls show Sanders is one of several candidates with a realistic chance of winning the first caucus state on Feb. 3.

His campaign drew 300,000 new donors in the fourth quarter, officials said, and surpassed 5 million contributions, many from donors giving repeatedly.

Sanders campaign manager Faiz Shakir said he believes contributions from new donors toward the end of year show that Sanders is convincing more voters that he can go the distance.

“When we are showing the path to success, guess what — people come out of the woodwork and they are like: ‘Oh, you know what? I’ve got 10 bucks for you. I’ve got 20 bucks for you,’ ” Shakir said in an interview Thursday at the start of a four-day bus tour through Iowa. “Hopefully, that also translates into votes.”

Asked whether he was bracing for wealthy donors who oppose Sanders to panic at the news of his huge fundraising, Shakir replied, “There’s been people who panicked about Bernie Sanders for a long time.”

Biden may reap the benefits of some of that establishment anxiety. Steve Schale, a Democratic strategist who heads the pro-Biden super PAC Unite the Country, said donors are committed to helping the campaign in early states. The group has spent $2 million in ads focused on Iowa.

Meanwhile, Trump’s attacks on the former vice president and his son’s work in Ukraine appeared to have buoyed Biden’s fundraising, campaign officials said. More than half of fourth-quarter donors were first-time givers, and online donations doubled, they said.

“Thank you for putting yourself on the line, vouching for me, vouching for the family,” Biden said in a video to supporters Thursday.

In a memo to supporters, campaign manager Greg Schultz wrote that Biden’s team is adding staff in early primary and caucus states.

As of New Year’s Day, Buttigieg is no longer mayor of South Bend, freeing up his time to spend on campaigning and raising money. He has at least one major fundraising swing planned out West before Iowa. His campaign did not respond to requests for comment on the campaign’s spending strategy.

The former mayor is now poised to rake in more money from donors in the financial industry who have already welcomed his candidacy. As mayor, he was limited by a federal pay-to-play contribution cap on bankers’ donations to local and state leaders who oversee public pension decisions.

A big question mark in the Democratic money race is the self-funded candidacy of billionaire businessman Mike Bloomberg, who has spent more than $100 million on campaign ads since entering in late November. Bloomberg, who is skipping the first four early-voting states, hopes to win enough delegates on Super Tuesday to forge a path to the nomination.

Meanwhile, Trump’s campaign has hired more than 400 staffers and plans to eventually bring aboard 1,500 spread across more than 300 offices in 17 states, according to a campaign official who briefed reporters last month.

The president’s reelection campaign, which has spent more than $50 million on its digital operation, added more online donors in 2019 than in 2017 and 2018 combined, according to a senior campaign official.

“The grass-level support is unprecedented,” said Lanza, the former Trump adviser. “The opposition to our agenda is unprecedented, and it will take unprecedented resources to level the playing field.”

Sullivan reported from Tama, Iowa. Chelsea Janes in Keene, N.H., and Amy B Wang in Washington contributed to this report.