The former labor secretary Tom Perez is the new chairman of the Democratic National Committee (DNC). His victory in Atlanta on Saturday saw him make history as the first Latino to lead the party but left progressives who backed his main opponent, US representative Keith Ellison, deeply disappointed.

Perez won the chairmanship on a second ballot, after missing out by just one vote in the first round of voting.

The threshold for victory in the second ballot was 218 votes, out of 435 voters. Perez gained 235 to 200 for Ellison. After announcing the result during the DNC’s winter meeting in Atlanta, acting chair Donna Brazile presented the gavel to Perez. He presented a motion to name Ellison as deputy chair, which passed unopposed.

The race for DNC chair became a symbol of divisions that opened during the 2016 presidential primary between Hillary Clinton and Bernie Sanders. Progressive activists said the outcome would be representative of their standing within the party.

Perez, who served in the Obama administration and was considered as running mate for Clinton, was viewed with suspicion by grassroots activists and progressive groups who believe he was urged to enter at the behest of the party’s so-called establishment. Ellison, the first Muslim member of Congress, is a longtime activist for grassroots causes.

The race was widely read as a proxy battle between the party establishment and progressive groups. Supporters of both sides worried the vote might sow new divisions.

Speaking after Perez’s win, Ellison made an appeal for unity. “If we waste even a moment going at it over who supported who,” he said, Democrats would be letting down the American people in their need to “confront Trump and beyond that”.

“We’ve got earnest sincere work to do under Chairman Perez,” he added, “and all of us and all of you are going to help him.”

Perez spoke after Ellison and made similar appeals while thanking his supporters and the other candidates. “I really want to apologise to the media because we did talk about issues,” he said, heralding like Ellison a campaign they said was free of partisan rancour. “We didn’t do any of the other stuff, and that’s what the Democratic party is about.”

Members voted by paper ballot and had two minutes to make their choice among the six candidates still in the running when voting began. The count was excruciatingly close. Perez finished the first ballot with 213.5 votes, having needed 214.5 to win. Ellison won 200 votes, taking the contest into a second round.

After the first ballot, all of the candidates withdrew except for Ellison and Perez. Jehmu Greene, a former Fox News political consultant who earned half a point, endorsed Perez. Peter Peckarsky, a Wisconsin attorney who earned no votes, endorsed Ellison.

In the frantic moments between the results and the distribution of the second ballots, the campaigns and their supporters spread across the convention center ballroom, in a last-ditch attempt to sway members to their side. Perez waded into the crowd, smiling and shaking hands as he secured commitments for a second round.

Ellison’s supporters wore green shirts that said “Keith for DNC” while Perez’s sported blue “Team Tom” gear.

Before voting began the mayor of South Bend, Indiana, Pete Buttigieg withdrew without endorsing a candidate, thereby unleashing at least a few dozen commitments late in the contest.

“We saw the potential of doing well on multiple ballots but we can do the math,” Buttigieg said, without endorsing a candidate. “It is time for this process to move toward a solution that we can all get on board with.”

Buttigieg, a popular, 35-year-old Rust Belt mayor and openly gay Afghanistan veteran, left the race after a streak of national media attention and without angering either faction. He is widely believed to hold higher political ambitions, especially as a young member of a party in search of new talent.

“There’s nothing wrong with our bench,” Buttigieg said. “We just haven’t called enough people on our bench off the bench and asked them to get out in the field.”

“Mayor Pete is going to be the example of how Democrats win statewide in red states,” said Perez in his remarks after winning the chairmanship.

The winner inherits a party demoralized not just by its election defeat but by years of losses at local, state and national levels. A surge of activism organized by liberal groups in reaction to an unpopular Republican president, however, offers hope of new purpose.

As chair – a role that in equal parts demands the work of a tactician, a fundraiser and an opposition leader – Perez will need to immediately begin preparing for races in 2017 and the midterms in 2018. Part of the challenge will lie in healing the ideological rift between centrist Democrats and progressives while developing a message to resonate beyond liberal enclaves.

Perez will also have to rebuild trust in an organization that was engulfed in controversy last year, after the publication of hacked emails that appeared to show committee staffers favoring Clinton over Sanders and led to the resignation as chair of Florida representative Debbie Wasserman Schultz.

The race to replace Wasserman Schultz attracted national attention and had all the trappings of a presidential campaign, with candidates embarking on bus tours and competing in televised debates.

But the vote was ultimately decided by 435 voting members of the DNC, which led Buttigieg to compare it to a “high school student council race”.