Former Labor Secretary Tom Perez has been elected chairman of the Democratic National Committee.

Perez bested Minnesota Rep. Keith Ellison on a second ballot during voting at the DNC Winter Meeting in Atlanta.

The former Obama administration official received 235 votes to Ellison’s 200 in the second round of voting. Ellison did not go away empty-handed, however. Perez’s first act as chairman was to appoint the progressive Democrat his deputy.

Some confusion erupted as the first ballot of votes were being cast. Ellison’s team sent out a text message to DNC voters claiming that he had received the endorsement of South Bend, Ind. mayor Pete Buttigieg, a candidate who dropped out of the race just before the vote.

Buttigieg clarified on Twitter that he had not endorsed anyone, and Ellison’s team sent a text retracting the endorsement claim.

The vote went to a second round after Perez fell just one vote shy of the 214.5 needed to win the chairmanship. Ellison received 200 votes on the first ballot while Idaho Democratic party executive director Sally Boynton Brown received 12. Another 4.5 votes were dispersed between abstentions and other candidates.

After the first round of voting, Brown and three other candidates, Jehmu Greene, Sam Ronan and Peter Peckarsky, dropped out of the contest. Brown did not provide an endorsement. Greene endorsed Perez while Ronan and Peckarsky endorsed Ellison.

Perez’s win is a victory for the establishment wing of the party. The one-time head of the Obama Justice Department’s civil rights office, Perez had the backing of his fellow administration colleagues, former Vice President Joe Biden and former Attorney General Eric Holder. He endorsed Hillary Clinton for president and was at one time considered to be in the running for her vice president.

Ellison was supported by the progressive and leftist faction, with his most prominent endorsement coming from Vermont Sen. Bernie Sanders.

But Ellison faced the most resistance of any candidate running for the top DNC spot. Conservatives hammered the converted Muslim over his past ties to the Nation of Islam, his anti-Semitic comments and his black nationalist remarks.

He also campaigned for a candidate for the Virginia assembly who called on Palestinians to embrace “the jihad way.” (RELATED: Keith Ellison Headlined Fundraiser For Muslim Activist Supports ‘The Jihad Way’)

Some major Democratic donors also opposed Ellison. Haim Saban, a heavy donor to Hillary Clinton’s campaign, said he opposed Ellison because of his comments about Israel. Alan Dershowitz, the lawyer, threatened to leave the Democratic party if Ellison won the DNC runoff. (RELATED: Longtime Democrat Dershowitz To Leave Party If Ellison Elected DNC Chair)

Perez’s selection will bring some much-needed stability to the DNC, which was rattled by WikiLeaks’ release of emails stolen from the party over the summer.

The release of the emails led to the resignation of chairwoman Debbie Wasserman Schultz. The stolen documents showed a preference among DNC leaders for Hillary Clinton over Vermont Sen. Bernie Sanders during the Democratic primaries.

Donna Brazile, a longtime Democratic party operative and TV analyst, replaced Wasserman Schultz as interim chair. But Brazile soon found herself in a controversy of her own.

Hacked emails released by WikiLeaks later in the campaign showed that Brazile provided the Clinton campaign with debate and town hall questions in March. The favoritism undercut Brazile’s claims that she was completely neutral between Clinton and Vermont Sen. Bernie Sanders.

Follow Chuck on Twitter