Perez was elected the first Latino chairman of the party on the second ballot at the winter meeting of the Democratic National Committee, and immediately named the runner-up, Minnesota Rep. Keith Ellison, deputy chairman in a gesture of unity.
President Barack Obama's labor secretary received 235 votes to 200 for Ellison from DNC members present, after having fallen short of a majority by one vote on the first ballot.
Even with the energy provided by opposition to President Trump and with the words of unity, Ellison's loss was a blow to the party's liberal wing. Activists, labor leaders, and community organizers backing Ellison packed the guest gallery of the meeting, and many protested as the result was announced. "Party for the people, not big money!" and "Money out of politics!" some chanted, while others muttered curses.
Before the voting, Perez said the Democratic Party faced a "crisis of confidence" and a "crisis of relevance" after losing about 1,000 seats from Capitol Hill to state legislatures during the last decade, in addition to Hillary Clinton's stunning loss.
Ellison, the first Muslim elected to Congress, was endorsed by Vermont Sen. Bernie Sanders and the AFL-CIO. For some backers of the two men, the campaign became a proxy of the bitter 2016 primary between Sanders and Clinton.
For all the differences in style, Perez and Ellison are on good terms, and the real story might well be the leftward pull of the Democratic Party. All of the candidates packaged themselves as progressives ready to battle Trump over civil rights, voting rights, and economic policies that favor the wealthy.
Perez, for instance, stressed his past as the head of the Justice Department's civil rights division, noting he had taken on Arizona Sheriff Joe Arapaio on immigration and battling GOP-controlled states to stop voter-ID laws.
It was the first DNC race since 1985 in which the winner was not clear heading into the vote. That was just after Walter Mondale's landslide loss to President Ronald Reagan.
Interim chair Donna Brazile, who did not run for election to her own term, and other senior party leaders were quietly urging DNC members not to let the election go to multiple ballots, fearing the spectacle could fuel the media narrative of a party in shambles after Trump's victory.
That wish was unfulfilled, as the winter meeting took on the feel of a contested convention. Some DNC members thought the energy of the experience was a good thing, while others were annoyed at being phoned and lobbied constantly.
The night before the vote at the Westin Peachtree Hotel, the buzz was that Perez was narrowly ahead, but that anything could happen, including the possibility a dark horse candidate, Mayor Pete Buttigieg of South Bend, Ind., could emerge after multiple ballots.
He had argued that the party needed a fresh start with a new generation of leadership. On leaving the race, Buttigieg urged the next chairman and Democrats to look beyond Washington, organize better for nonpresidential elections, and "pay attention to communities like ours, in the heartland of the country – not as an exotic species but as your fellow Americans."
The immediate challenges for Perez are to unite the party, raise money, and help state parties get ready for legislative and gubernatorial races before the congressional reapportionment that will follow the 2020 census. He also wants to build alliances with other groups battling Trump.
"The moms and dads at town halls and marches against Trump are not thinking about the DNC," said Adam Green, cofounder of the Progressive Change Campaign Committee. "The big question moving forward is will Democrats have their fingers on the pulse of the grassroots resistance? We wish Tom Perez luck."
On that score, a resolution to reimpose Obama's ban on the party's taking money from lobbyists or corporations failed to advance on a procedural vote. Rep. Debbie Wasserman-Schultz, the former DNC chair, reversed that policy during Clinton's campaign last year.