WASHINGTON (AP) — Republicans have elected South Dakota Sen. John Thune as the next Senate majority leader, completing a momentous shift in their leadership that elevates a top deputy of Mitch McConnell into a key position as President-elect Donald Trump returns to the White House.

Thune, 63, is in his fourth Senate term and has promised to work closely with Trump, despite differences the two have had over the years, and will be a crucial part of the incoming president’s efforts to push through his policy agenda. The two spoke on the phone shortly after Thune was elected, the senator posted on X Wednesday afternoon, adding that “Senate Republicans are excited and ready to get to work” with the incoming president.

Trump later congratulated Thune on his social media platform, Truth Social. “He moves quickly, and will do an outstanding job,” Trump wrote. “I look forward to working with him.”

Thune beat out two other competitors, Sens. John Cornyn and Rick Scott, by gaining majority support from GOP senators in two rounds of secret ballots behind closed doors. Scott was eliminated on the first round and the final vote between Thune and Cornyn was 29-24, according to several people who requested anonymity to discuss the private meeting.

Republicans are replacing McConnell, the longest serving Senate party leader, as they prepare to take majority control of the Senate with the 53 seats they won in last week’s elections. It was the first competitive election for Republican leader in three decades and Senate Republicans’ first regime change since McConnell became GOP leader in 2007.

Thune’s election represents a major shift in the upper chamber’s GOP conference as many senators have been eager to move on from McConnell’s long and powerful reign. But it will also be a complicated test for Thune as he will have to manage a conference that is often divided over policy, navigate Trump’s demands of the legislative branch and secure policy wins for the president as he begins his second term.

“It is a new day in the United States Senate,” Thune told reporters immediately after he was elected. He said his majority will work to toughen border security laws, lower energy costs and overturn regulations they see as burdensome.

“We are excited to reclaim the majority and to get to work with our colleagues in the House to enact President Trump’s agenda,” Thune said.

As the candidates tried to win over individual senators, all of their pitches centered around how close they would be to Trump. That was a more difficult task for Cornyn and Thune, who broke publicly with the former president over his effort to overturn his defeat in the 2020 presidential election and the Jan. 6, 2021 attack on the Capitol. At the time, Thune called Trump’s actions “inexcusable.”

In recent months, though, Thune has worked to smooth over that relationship, visiting Trump at his Florida home and consulting with him on how to implement the incoming president’s agenda. Thune told The Associated Press over the summer that he views their potential relationship as a professional one. If they both won their elections, Thune said then, “we’ve got a job to do.”

As he made his case, Thune has made clear that he will listen to Trump’s demands. When Trump posted on X Sunday that the new leader “must agree” to allow him to appoint Cabinet members and others when the Senate is on recess, avoiding confirmation votes, Thune quickly responded in a statement that the Senate must “quickly and decisively” act to get nominees in place and that “all options are on the table to make that happen, including recess appointments.”

Speaking to reporters after he was elected, Thune noted that “the Senate has an advise and consent rule in the Constitution” but that they will do everything they can to get his nominees in place.

“How that happens remains to be seen,” Thune said.

Thune’s win is all the more extraordinary because of his 2004 election to the Senate – defeating then-Senate Majority Leader Tom Daschle after arguing during the campaign that Daschle had lost his South Dakota roots during his years in Democratic leadership. Twenty years later, Thune will become majority leader himself.

Well liked and a respected communicator, Thune has been perceived as a front-runner for much of the year. Like McConnell, he hails from the Republican Party’s more traditional wing.

He is a former chairman of the Senate Commerce Committee and has held the Republican whip position — no. 2 in party leadership — since 2019. He took over for McConnell for several weeks last year when he was on a medical leave, a move that was widely seen as an audition of sorts as speculation surrounded McConnell’s future.

As he geared up to run for leader, Thune spent much of the year campaigning for his colleagues. According to his aides, he raised more than $31 million to elect Senate Republicans this cycle, including a $4 million transfer from his own campaign accounts to the Senate’s main campaign arm.

The election was difficult for many in the conference who saw Thune and Cornyn as similar choices. They are alike on policy, voting generally in step with the conference but working with Democrats at times. Cornyn is a longtime member of the Senate Judiciary Committee who took a leading role on bipartisan gun legislation two years ago.

But the two differed on whether the leader should be term limited — a key demand from some in the conservative wing. Cornyn pushed for limits, while Thune did not.

Scott, the former governor of Florida, was elected to the Senate in 2018 and quickly positioned himself as a foil to McConnell, running against him for leader in 2022 and aligning with Utah Sen. Mike Lee and others who have been highly critical of the current leadership.

As Thune and Cornyn wooed their colleagues one by one all year, Scott was tied up in his own reelection race. He handily defeated Democrat Debbie Mucarsel-Powell by more than 10 points.

In the week since the election, Scott aggressively stepped up his campaign for GOP leader, campaigning publicly as the candidate closest to Trump and winning endorsements from people who are close to the former and future president, such as billionaire Elon Musk. But some questioned whether that strategy might backfire.

South Dakota Sen. Mike Rounds, Thune’s home state colleague, said that he prefers the way that Thune and Cornyn have “handled it one-on-one with everybody,” but that he had talked to Scott as well. “We’ve got three qualified individuals,” he said ahead of the race.

Still, both Thune and Cornyn adopted some of Scott’s ideas as they worked to win over voters. Thune told the conference in a candidate forum Tuesday evening that he would allow more amendments on the floor and improve communication from McConnell’s regime, addressing frequent complaints from that wing of the conference.

McConnell did not say who he was supporting, but said after the vote that Thune’s victory was a “clear endorsement of a consummate leader.”

“The American people elected Republicans to restore stability and order after four years of Washington Democrats’ failure,” McConnell said. “John Thune will take the reins with a tremendous opportunity to lead this transformation, and Senate Republicans stand behind him, ready to get to work.”