SELMA, N.C. — Donald Trump came to town at just the right moment — in time to witness his chosen candidate finally emerge as the front-runner in the state’s contentious Senate primary.

After struggling for months to take the lead, polls released last week show GOP Rep. Ted Budd has a commanding advantage, ending speculation that the former president badly miscalculated with his early and unexpected endorsement of the little known House member.

It’s a relief for Trump, whose endorsement record will be closely scrutinized in advance of a possible 2024 presidential bid. He’s already seen one of his endorsed Senate candidates drop out of the race in Pennsylvania, and another flounder in Alabama, where the former president pulled his endorsement from Rep. Mo Brooks last month.

North Carolina’s May 17 GOP primary will serve as one of the year’s first major tests of his clout within the party.

“I’m very proud of that man,” Trump said of Budd at a Saturday rally here in eastern North Carolina. “Not an easy thing to do, what he’s doing, and he did it so well. And we gotta get out there to vote. Make sure you’re voting.”

Trump, calling Budd “by far the best candidate in the race,” teased an unnamed poll he said he had seen earlier in the day showing Budd with a 17-point lead in the primary — a stark contrast with polls in late February that showed Budd six to 11 points behind former Gov. Pat McCrory.

“That’s a big lead,” Trump said. “That’s a big lead.”

Budd’s surge coincides with a deluge of spending by the Club for Growth, a conservative super PAC pouring $15 million into the Republican primary to support his candidacy. The congressman also now has the backing of one of the state’s most popular Republicans, Lt. Gov. Mark Robinson — an endorsement likely to increase his support among conservative evangelicals.

“Our party needs to come together,” said Robinson, who, outside of Trump, received the most enthusiastic reception of the rally speakers. “We need to join together and make sure that we can send a strong, principled conservative candidate to Washington — that we can push him through this primary and blast him past his Democratic opponent in the general election.”

Robinson’s endorsement of Budd comes after the popular lieutenant governor spent recent weeks traveling with and publicly praising one of Budd’s GOP opponents, Mark Walker. Robinson said at an event last month that Walker was “going all the way to the top,” and that Robinson would do all he could to help him.

Walker, a former congressman, has stayed in the race despite efforts by Trump and his allies to get him to drop out. In a statement to POLITICO Sunday, Walker said he was “offered several deals this past week to get out of the Senate race” if he agreed to appear at the rally and endorse Budd. He declined to elaborate on what he was offered, or by whom.

“I didn’t play this game in D.C. and I won’t do it now, thus, declining their offer,” Walker said, adding that he is “disappointed” by Robinson’s endorsement, but would continue to work to earn voters’ support.

Budd’s campaign said they’ve had no conversations with Walker.

The trajectory of Budd’s campaign has differed dramatically from Brooks, who also received Trump’s endorsement last year for a Senate primary set for May.

Brooks also failed to pull ahead in the polls, before Trump rescinded his support in late March. Pointing to comments the congressman had made about Republicans needing to move on from the 2020 election as the reason he was withdrawing his backing, Trump said Brooks had “gone woke.”

Last week, a super PAC supporting Walker sought to draw a similar reaction by texting Republican primary voters a video of Budd saying Joe Biden was the legitimate president and agreeing that Trump had received 7 million fewer votes than Biden. But Budd’s comments, made during an October interview with the Associated Press, failed to gain traction in the news or receive a public reaction from Trump, who praised Budd on Saturday for prioritizing election integrity.

Budd said in an interview that the recent surge in support and enthusiasm for his campaign could, in part, be attributed to the state’s congressional redistricting issues being resolved, and more certainty about the date the primary would be held.

“North Carolinians are starting to focus on this race,” Budd said. “That’s why we’re seeing our poll numbers go up.”

“We’ve got a lot of work ahead. We want to be humble. We want to work hard, we want to stay focused over the next 38 days. We want to get onto the real race, which is in November.”

The Republican Senate nominee will likely face Cheri Beasley, a former state supreme court justice who cleared the Democratic field months ago.

McCrory spent Saturday evening in Charlotte, where he said he was “meeting with a very significant group of potential voters.” Walker’s campaign had solicited volunteers to take part in voter outreach in Greensboro earlier in the day.

In an interview, McCrory insisted the race remains close and “will probably be decided by 1 to 2 points.” A candidate needs to secure more than 30 percent of the vote to avoid a July 26 runoff.

The former governor decried the Club for Growth’s massive spending against him, saying the super PAC was “trying to buy a Senate seat.”

“And no one from North Carolina knows who this group is or who’s paying for it,” McCrory said.

The super PAC is expected to shatter its own spending record for a race. The group’s ads have attacked McCrory as a moderate Republican who is opposed to Trump.

Asked about claims by McCrory and Walker that the conservative super PAC is buying Budd a seat, Budd praised the Club for Growth.

“They’re for small government, they’re for lower taxes,” Budd said. “It’s a shame that my opponents are not for those things, because that’s what that group’s for.”

On stage at the rally Saturday, Trump called Club President David McIntosh a “very powerful man.”

“We are undefeated when we work together,” Trump said of the Club, which also endorsed Rep. Madison Cawthorn and Bo Hines, a first-time candidate running for an open House seat in the 13th congressional district, where the rally took place.

Some Republican activists in the district, including those who attended the rally Saturday, have resisted Hines’ candidacy, arguing he has little to no ties to the district and lives hours away. In anticipation of Hines’ appearance at the rally, one of his Republican opponents, DeVan Barbour, lined the rally entrance road with campaign signs and greeted attendees as they arrived.

At least one Barbour supporter was asked to move from his bleacher seat on the stage directly behind the podium. Dale Lands said when he asked security staff why he was being instructed to move, the security guard cited comments Lands made in a recent POLITICO story about local efforts to stop Hines from winning the Republican nomination.

Budd, however, received an enthusiastic response from the crowd, prompting chants of “Build that wall” and “Joe’s gotta go” during his speech.

The event Saturday proved successful at helping rally support for Budd, at least from local party activists. When Trump announced in late March he would be holding a rally in the state, “it was like flipping a light switch” in terms of interest from campaign volunteers, according to a Budd official.

Budd’s campaign had held off on grassroots organizing until it was clear when North Carolina would hold its primary, but in recent weeks has established a volunteer network in all 100 counties of the state.