President Trump is greeted by South Carolina Gov. Henry McMaster and his wife Peggy McMaster as he heads to Greenville, S.C., for a fundraiser. (Carolyn Kaster/AP)

President Trump came to a golf resort here Monday to help raise money for South Carolina’s governor, making his first foray back onto the campaign trail since the embarrassment of siding with the losing Republican primary candidate in Alabama’s special Senate race.

As was the case in Alabama last month, Trump’s trip South to support an establishment candidate was driven partly by loyalty: During Trump’s presidential campaign, South Carolina Gov. Henry McMaster (R) — then the lieutenant governor — was the first statewide elected official in the country to throw his support behind the real estate executive and reality television star.

McMaster, a stalwart of South Carolina politics for the past three decades, was elevated to governor in January when Trump picked Nikki Haley to serve as ambassador to the United Nations. Now, McMaster is facing a primary challenge from a well-funded candidate who has cast herself as the insurgent in the race.

Catherine Templeton, a Mount Pleasant lawyer who headed two agencies during Haley’s administration, says she is running against the Palmetto State’s “good ol’ boys” network and has promised to be a force against a government that has “gotten too big and too self-serving.”

Two other Republicans are also challenging McMaster for the party’s nomination in June in a state where the GOP has held the governor’s mansion for 26 of the past 30 years.

“A lot of folks are reassessing their assumptions that McMaster would coast,” said Scott Huffmon, a political scientist at Winthrop University in Rock Hill, S.C., who added that another of the GOP contenders could siphon some evangelical support from the sitting governor.

The evening fundraiser for McMaster, at the Embassy Suites Golf Resort and Conference Center here, was closed to the news media, which gathered across the street. Tickets to the event, held in a room that could hold 1,200, started at $250.

“He’s a talented guy, and he’s doing really well,” Trump said of McMaster, according to what appeared to be a cellphone video posted to the website of The State newspaper of Columbia, S.C., on Monday night. “He’s a terrific person, a terrific man. … I’m so happy with the job he’s done.”

Trump was greeted before the event at the airport by McMaster, his wife and their two adult children, after a flight on Air Force One that also ferried Sen. Lindsey O. Graham (R-S.C.) and Rep. Joe Wilson (R-S.C.) to the event.

Trump’s decision to get involved in the South Carolina race underscores the difficult political calculus for the White House on how to deploy the president.

Governor’s races in two states — New Jersey and Virginia — will be decided next month, and Trump has not yet set foot in either place to stump for his party’s nominee.

In New Jersey, there has been no shortage of opportunities, with Trump’s frequent travels to his golf resort in Bedminister. His time there included a 17-day “working vacation” this summer in which he did not cross paths with the GOP gubernatorial nominee in the Garden State, Lt. Gov. Kim Guadagno (R).

Guadagno is trailing in the polls in the Democratic-leaning state, facing the head winds of both an unpopular president and unpopular incumbent Republican governor, Chris Christie.

In Virginia, Trump has inserted himself into the race via Twitter, sending multiple messages praising the Republican gubernatorial nominee, Ed Gillespie, a former Republican National Committee chairman, who is taking on Democrat Ralph Northam, the state’s lieutenant governor.

“The Democrats in the Southwest part of Virginia have been abandoned by their Party. Republican Ed Gillespie will never let you down!” Trump said in a tweet last week.

But some Trump associates are advising him not to tie himself more closely to Gillespie in a state that Trump lost by 5 percentage points last year and where President Barack Obama is among the heavy hitters being brought into bolster the candidacy of Northam.

“I think it would be malpractice to send him into Virginia, this close to the election, knowing there’s a real possibility of a second embarrassing loss in a row,” said one Republican consultant close to the White House.

When the Republican National Committee met in California in May, Trump appeared via a taped message in which he suggested he would like to be heavily involved ahead of next year’s midterms — but whether that turns out to be the case remains to be seen.

“I’ll be going around to different states,” Trump said. “I’ll be working hard for people running for Congress and the people running for the Senate. We can pick up a lot of seats, especially if it keeps going the way it’s going now.”

Although there are some emerging parallels between the South Carolina governor’s race and the Alabama Senate contest, there are some distinct differences as well.

Templeton, who has never held political office, is largely unknown statewide. In Alabama, Roy Moore, the insurgent GOP candidate who prevailed over the Trump-backed Sen. Luther Strange, has a long and colorful history. He is a former state chief justice who was twice removed from the bench for defying judicial orders.

Trump arrived in South Carolina on the heels of reports showing Templeton raised more money than McMaster in the past three months. McMaster, whose resume also includes stints as South Carolina’s attorney general and state GOP chairman, has still raised more for the year, but both candidates report about the same amount of cash on hand.

Dick Harpootlian, whose tenure as chairman of the South Carolina Democratic Party chairman overlapped with McMaster’s service as the state GOP chairman in the 1990s, said McMaster “is a rational politician who likes to put a consensus together to try to move the ball forward.”

“He’s not a bomb thrower,” Harpootlian said. “It’s more likely that the insurgents in the Republican Party will be gravitating toward Templeton.”