Tom Perez, the most recent secretary of labor under Barack Obama, was elected the next chairman of the Democratic National Committee, after a contentious vote to lead the party after its devastating loss in November.

Perez’s chief opponent in a large field of candidates was Keith Ellison, a congressman from Minnesota, who was endorsed by Bernie Sanders.

“I am confident that when we lead with our values and lead with our actions, we succeed,” Perez said at the DNC’s winter gathering in Atlanta.

Perez won 235 votes to Ellison’s 200 on a second ballot of DNC member after no candidate claimed a majority in the initial vote.

Perez immediately made a move to try to unify competing factions, calling for Ellison to be named deputy chair of the DNC.

Ellison told the gathering that “we don’t have the luxury to walk out of this room divided.”

The vote was characterized as a battle of party establishment, represented by Perez, versus a more insurgent liberal wing of the party, represented by Ellison. That did not always match the rhetoric coming from major candidates or even their endorsements.

Ellison, for instance, garnered endorsements not just from Sanders but from Senate Minority Leader Chuck Schumer (D-N.Y.). And Perez, who was endorsed by former Vice President Joseph Biden, was viewed as one of the more progressive voices during his tenure in the Obama administration. As Hillary Clinton considered potential running mates, he was seen as a pick who could please the left wing of the party.

A dark-horse candidate was Pete Buttigieg, the mayor of South Bend, Ind., who was endorsed by former DNC chair Howard Dean. But Buttigieg dropped out of the race on Saturday afternoon, before voting began, acknowledging that he did not have enough support to make a showing. Dean endorsed Ellison after the first ballot.

Despite his significant support, Ellison was criticized by some major party donors, including Haim Saban, who in December said that he was “clearly an anti-Semite and anti-Israel individual.” It was a reference to Ellison’s previous writings about the Nation of Islam and its leader, Louis Farrakhan. Ellison, the first Muslim American elected to Congress, said that he had long since distanced himself from Farrakhan and renounced their “bigoted and anti-Semitic ideas and statements.”

Perez played down any divisions in his first speech after being elected chair. “I want to apologize to the media because we did talk about this issues, We didn’t talk about the other stuff,” Perez said, suggesting that the disagreements among the candidates were overhyped.

Sanders, who is an independent, issued a statement congratulating Perez but also warning him that it was “imperative” that he “understands that the same-old, same-old is not working and that we must open the doors of the party to working people and young people in a way that has never been done before.”

The election was unusual in that it drew some interest beyond party insiders. Cher tweeted out her support for Buttigieg on Friday, and Gloria Steinem backed Ellison several weeks ago.

Perez succeeds Debbie Wasserman Schultz, who resigned as chair in July, on the eve of the Democratic National Convention, after embarrassing details on party operations were leaked after the DNC’s computer system was hacked. Donna Brazile served as acting chair in the interim.

In his victory speech, Perez also turned the focus on winning seats at all levels, as Democrats find themselves at a low ebb when it comes to control of the White House, Congress and statehouses across the country. He called President Trump “the worst president in the history of the United States” and said that he would be a one-term president.