Newly elected Democratic National Committee Chairman Tom Perez gives a victory speech during the general session of the DNC winter meeting in Atlanta, Saturday, Feb. 25, 2017. Associated Press/Branden Camp President Donald Trump offered a backhanded congratulations to former Labor Secretary Tom Perez, who was narrowly elected chairman of the Democratic National Committee on Saturday.

"Congratulations to Thomas Perez, who has just been named Chairman of the DNC. I could not be happier for him, or for the Republican Party!" Trump tweeted.

Perez responded shortly afterward:

"Call me Tom. And don't get too happy. @keithellison and I, and Democrats united across the country, will be your worst nightmare," he tweeted.

Perez won the chairmanship after a close race that was called after multiple rounds of balloting, eking out a victory over Rep. Keith Ellison of Minnesota.

Perez's victory has been viewed by some as as a slight against the more progressive faction within the Democratic Party, which had largely supported Sen. Bernie Sanders of Vermont during his primary battle against Hillary Clinton.

The race between Perez and Ellison was frequently compared to that of Clinton and Sanders, with Perez being seen as the establishment figure and Ellison as the populist who could more effectively help the party appeal to working-class voters.

Trump offered Ellison praise earlier in the week for predicting early in the 2016 campaign cycle that Trump could have staying power in the presidential field.

"One thing I will say about Rep. Keith Ellison, in his fight to lead the DNC, is that he was the one who predicted early that I would win!" Trump tweeted.