ATLANTA (CBSNewYork/AP) — Democrats elected former Obama Labor Secretary Tom Perez as their national party chairman Saturday afternoon, ending a long, competitive battle to choose a new leader who will attempt to turn widespread opposition to President Donald Trump into more election victories.

Perez won over Keith Ellison, a Minnesota congressman, in the second round of voting Saturday by Democratic National Committee members at their meeting in Atlanta.

READ MORE: Suspect Charlie Vasquez Charged In Shooting That Injured 2 NYPD Officers In The Bronx

The former Labor Secretary under the Obama administration, who grew up in Washington Heights, vowed to energize the party on the grass roots level. Then, in a show of unity, Perez then named his top rival, Ellison, to be his deputy.

“We’re in this mess because we lost not one election, but a thousand elections. And we’re going to get out of it when we win elections,” he said.

The president posted his reaction on Twitter, saying, “Congratulations to Thomas Perez… I could not be happier for him, or for the Republican Party!”

Perez gave a speech before the vote and said Democrats face “a crisis of confidence” and a “crisis of relevance.” He pledged to “take the fight” to Trump and “right-wing Republicans.”

Both frontrunners took to Twitter early Saturday to make a last pitch to prospective voters.

The outgoing chairwoman, Donna Brazile, told Democratic National Committee members that this promised to be a “very special day for our party.”

The candidates pledged to combat Trump and the GOP aggressively.

READ MORE: New Video Shows Suspected Gunman, Car Used To Flee Scene Of Deadly Bronx Double Shooting

“We are fighting for a party that is not the status quo,” Ellison told his supporters late Friday, arguing that Democrats have become too timid and lost touch with too many voters across much of the country by abandoning working people. The key, he said, is to “knock on doors and engage people” while pushing policies that benefit them. “Let’s have a debate,” he said. “You’re not scared. I’m not scared. Let’s do it.”

Perez has said the party must be the center of Trump resistance.

“The most important word in a democracy is that simple two-letter: `We,”‘ he said at a nearby reception, promising he would help Democrats capitalize on the budding opposition movement. “It’s amazing what we can accomplish when we have strong parties everywhere that allow us to put those values into action.”

Perez got into the race at Obama’s urging, but he has pushed back on the notion that represents the same “establishment” label that dogged Hillary Clinton’s presidential campaign. Ellison has endorsements from Vermont Sen. Bernie Sanders, who challenged Clinton for the Democratic nomination, and also from Senate Minority Leader Chuck Schumer.

Clinton has stayed out of the DNC contest, but she made a video appearance at the party gathering Friday. “Let resistance plus persistence equal progress for our party and our country,” she said, praising the Jan. 21 women’s marches across the country and other signs of public criticism of Trump. She also indirectly noted her popular vote victory, which Trump has insisted was not legitimate. “Nearly 66 million votes,” she said, “are fueling grassroots energy and activism.”

Democratic mayors of the nation’s two largest cities had taken opposite sides. Los Angeles Mayor Eric Garcetti was at the meeting campaigning for Perez. New York City Mayor Bill de Blasio was lobbying members on Ellison’s behalf.

New York Gov. Andrew Cuomo released a statement late Saturday night, congratulating New York’s own Congresswoman Grace Meng and Assemblyman Michael Blake on being elected Executive Vice Chairs of the Democratic National Committee.

“From investing in education and creating good-paying jobs to protecting immigrants’ rights and advancing issues of social justice, Congresswoman Meng and Assemblyman Blake will help lead the fight to ensure our nation remains a beacon of hope and opportunity for everyone,” it read in part.

MORE NEWS: The History Of The Brooklyn Bridge: 'Such An Iconic Piece Of New York City And Beyond'

© Copyright 2017 CBS Broadcasting Inc. All Rights Reserved. The Associated Press contributed to this report.