Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

ATLANTA — Tom Perez's prize for winning Saturday's dramatic Democratic National Committee leadership election is a divided and out-of-power party that’s already stuck between its base and President Donald Trump.

The party’s new chairman will have to heal its internal divisions, position it for battle with the White House, and rebuild its political infrastructure for the long term — all at the same time.

"The first job is like three jobs in one," said Randi Weingarten, the president of the powerful American Federation of Teachers union and a DNC member.

The protests that nearly drowned out Interim Chairwoman Donna Brazile when she announced the results of the election made the challenges clear to Perez, who bested Rep. Keith Ellison on the second round of voting after Perez fell a single vote short on the first.

Related: Tom Perez Becomes DNC Chair in Close Election Victory

Meanwhile, Trump’s tweet sarcastically congratulating the former labor secretary on his victory was a reminder that Perez is coming late to an already heated internal debate about how much the party should obstruct Trump and which lines of attack it should choose from the myriad of possibilities.

Congratulations to Thomas Perez, who has just been named Chairman of the DNC. I could not be happier for him, or for the Republican Party! — Donald J. Trump (@realDonaldTrump) February 25, 2017

The backlash to Trump, whose unfavorable numbers have climbed since he's taken office, could be an enormous opportunity for Democrats. But the party has to find a way to sustain the opposition until next year’s midterm elections and convert it into votes.

Perez, the DNC's first Latino leader, earned cheers for calling Trump "the worst president in the history of the United States" Saturday, but demurred when asked if he agreed with Ellison’s charge that the president had already committed impeachable offenses.

It's just one of many points of conflict that are likely to emerge after an intense leadership campaign — the party's first contested chairmanship election in more than three decades — that inflamed lingering tensions from last year's presidential primary between Hillary Clinton and Bernie Sanders.

"I recognize I have a lot of work to do. I recognize I have a lot of listening to do," Perez, hoarse after a long race, told reporters.

"For people who already feel marginalized by the party, it's like a punch in the gut."

Perez made a down payment on that goal by immediately naming Ellison deputy DNC chairman, a position created specifically for the Minnesota congressman, who urged his supporters to give Perez a chance.

"I trust Tom Perez. If you trust me, then you've got to come on board with Tom Perez," Ellison said, standing next to Perez.

Perez chafed at the "establishment" mantel he inherited when he got into the race a month after Ellison at the urging of people close to former President Barack Obama and Hillary Clinton, but he understood the reality of the situation.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

And it will take more than symbolism and nice words to win over skeptics.

Ellison allies saw the election as a choice between the party's base and its incumbent leadership class. But in an insider's race like this one, in which only the 447 members of the DNC got to cast a ballot, the odds were always long.

Ellison's 200 votes on the first ballot — within striking distance of the necessary threshold for victory — surprised some Perez allies, whose whip counts pegged his support lower. But in the end, the establishment won again.

"For people who already feel marginalized by the party, it's like a punch in the gut," said Melissa Byrne, a former Sanders staffer who ran a longshot bid for DNC vice chair.

By all accounts, Ellison and Perez are friends, and Ellison’s district was the one Perez visited most while heading the labor department.

"For the two of us, that is easy," Perez said of joining forces. "Because we were always united in our values."

And supporters say Perez, who brokered several high-profile disputes between management and labor unions as labor secretary, can do the same between factions inside the Democratic Party.

"Tom has an instinctive ability to be a dealmaker and consensus builder," Los Angeles Mayor Eric Garcetti said in an interview. "He’s a really likable person. So this is not an election in which retribution is going to be directed against people who did not support you."

"I know that Tom Perez will unite us under that banner of opportunity."

But it will be much harder for Ellison supporters who don't know Perez personally.

"It's a loss for the DNC and the Democratic Party, not for Keith," said Eric Thut, the new executive director of Netroots Nation, one of the largest annual gatherings of progressives, who supported Ellison.

In the front of the ballroom where voting occurred Saturday, DNC members from both factions moved quickly to show unity. They cheered Perez and adopted a motion to record for posterity their vote as unanimous.

Keith Ellison gestures to newly-elected DNC Chair Tom Perez in Atlanta on Feb. 25, 2017. ERIK S. LESSER / EPA

But in the back of the room, where members of the public were allowed to watch the debate, green-shirted Ellison supporters erupted in deafening chants of "no big money! Party for the people!" when the results were announced.

Perez can build credibility with those activists, progressives say — it will just take a lot of work that could be avoided if the party had chosen Ellison.

"The leaders of the Democratic Party missed an opportunity today," said Dan Cantor, the national director of the Working Families Party, a liberal group that has organized recent protests targeting both Democratic and Republican members of Congress.

"Since Inauguration Day, millions of people around the country have marched against Trump. Keith Ellison was uniquely qualified to transform that anger and fear into political power and organization," Cantor added.

And they worry the party will lose those activists forever if they’re not made to feel that they have as seat at the table.

"Unless he figures out a way to start building a bridge to those people, we’ll see the hashtag #DemExit trending on Twitter," said Jane Fleming Kleeb, the chairwoman of the Nebraska Democratic Party and a Ellison supporter.

Perez allies are sometimes baffled by that kind of talk.

In a parallel universe, liberals would be clamoring to have President Hillary Clinton appoint Perez Attorney General.

Interim chair Donna Brazile, left, hands the gavel to newly-elected DNC Chair Tom Perez. ERIK S. LESSER / EPA

And in selecting Perez, who was the most liberal member of Obamas's cabinet, the party clearly solidified a left turn.

As a Latino civil rights attorney, bureaucrat, Brown University graduate, organized labor booster, and proud resident of uber liberal Takoma Park, Maryland, Perez is a clear break from the party’s businesses-friendly previous chairs, Rep. Debbie Wasserman Schultz and Virginia Sen. Tim Kaine.

"I know that Tom Perez will unite us under that banner of opportunity," Obama said in a statement.

Perez also will have to get to work immediately to rebuild the party’s infrastructure, which withered under Obama.

State parties have been neglected, while the party’s national headquarters was demoralized by the publication last year of hacked emails that lead to the abrupt departure of chairwoman Wasserman Schultz.

All that will require money. Lots of it.

"I would expect that in a year when you don't have the White House, at least 70 percent of that job will be related to raising money," said Henry Munoz, the DNC’s longstanding finance chairman, who was re-elected Saturday.