Republicans on Wednesday elected Sen. John Thune of South Dakota, their No. 2 in the chamber, to serve as majority leader in the next Congress, choosing a party institutionalist to replace Sen. Mitch McConnell of Kentucky, the Senate’s longest-serving leader.

In elevating Thune, 63, GOP senators turned to a traditional Republican in the mold of McConnell, and rejected a challenger more aligned with President-elect Donald Trump’s Make America Great Again movement.

In a closed-door vote conducted by secret ballot, Thune emerged victorious by a vote of 29-24 over Sen. John Cornyn of Texas, another well-respected establishment Republican, according to two people familiar with the vote. Sen. Rick Scott of Florida, who pitched himself as the Trump candidate in the race and had been supported by right-wing allies of the president-elect, was forced out of the contest in an earlier round of voting after drawing just 13 supporters, well behind Thune and Cornyn, they said.

After Thune had won, Cornyn called for him to ascend to the leader position through acclamation — or without objection or dissent — a move that signaled the Senate would retain some of its civility in the raucous world of the MAGA movement.

The outcome suggested that the Republican-controlled Senate would keep some independence from Trump. But it was unclear whether the private show of resistance to a Trump ally would translate into public defiance of the newly elected president.

Over the years, Thune has been no automatic yes-man to Trump. He opposed Trump’s efforts to overturn the 2020 election and initially endorsed Sen. Tim Scott of South Carolina for the presidential nomination.

But in his acceptance speech, Thune made clear he knew it was his job to deliver Trump’s legislative priorities through the Senate.

“We are excited to reclaim the majority and get to work with our colleagues in the House to enact President Trump’s agenda,” Thune said, adding: “We will make sure that the president and his team have the tools and support that they need to enforce border security laws and to remove the violent criminals who are wreaking havoc in every one of our states.”

Thune also suggested that the Senate would carry out its constitutional responsibility as a check on the presidency. He said he would maintain the Senate’s legislative filibuster, which would mean that Democrats could block certain legislation if Republicans will not compromise with them. And he said the Senate would continue to vet nominees to Trump’s administration. Still, he left open the idea he might embrace Trump’s demand to use recess appointments to force through his more troubled nominees should the Democrats throw up too many roadblocks.

“We want to make sure our committees have confirmation hearings like they typically do,” Thune said.

Only hours later, it became clear that keeping Trump’s nominees on track could be a tricky endeavor for Thune. Several Republicans were shocked Wednesday afternoon at the news that the president-elect had chosen Rep. Matt Gaetz, R-Fla., to serve as his attorney general and questioned whether he could draw the votes necessary to be confirmed.

In addition to Thune’s victory, several other Republican senators were voted in as members of the leadership team. Sen. John Barrasso of Wyoming captured the No. 2 post; Sen. Tom Cotton of Arkansas defeated Sen. Joni Ernst of Iowa for the No. 3 position; Sen. Shelley Moore Capito of West Virginia took the No. 4 job; and Sens. James Lankford of Oklahoma and Tim Scott also were elected to leadership.

The switch in leadership in the Senate represented a remarkable moment after McConnell has held on to power there for 18 years nearly without challenge.

Thune made his case in an opinion essay on Fox News on Monday, arguing that Senate Republicans needed to fulfill Trump’s promises to voters in order to keep the support of a multiethnic, multiracial coalition that swept him into a second term.

“If we fail to deliver on President Trump’s priorities, we will lose their support,” he wrote. “They have trusted us with their votes. Now we have to roll up our sleeves and get to work.”

The former president has railed against Thune in the past over his refusal to go along with Trump’s attempt to overturn the 2020 election. Trump referred to Thune as a “RINO” — Republican in name only — and called him “Mitch’s boy.”

And he vowed to run a primary opponent against Thune, promising to end his political career. But Thune has worked to improve his rapport with the president-elect.

While allies of Trump lambasted senators who refused to endorse Rick Scott, Trump did not ultimately weigh in himself, perhaps sensing Scott could not win.