WASHINGTON (Reuters) - U.S. Representative Mark Sanford is the latest Republican to learn a tough lesson - challenging President Donald Trump can be political suicide.

FILE PHOTO: U.S. Rep. Mark Sanford (R-SC) questions U.S. Department of Homeland Security Secretary Jeh Johnson on President Obama's executive action on immigration as Johnson testifies at a House Homeland Security Committee hearing on Capitol Hill in Washington, December 2, 2014. REUTERS/Jim Bourg/File Photo

The South Carolina Republican congressman’s upset loss on Tuesday to a primary opponent who questioned his commitment to Trump, along with a recent setback for Trump critic Martha Roby in Alabama and the Senate nomination of a controversial anti-establishment Trump supporter in Virginia, reinforced the degree to which loyalty to Trump has become a party litmus test.

While fealty to the Republican president may be a requirement to win low-turnout Republican primaries dominated by conservative activists, it could prove a tougher sell against energized anti-Trump Democratic forces in midterm elections this fall.

“A lot of Republicans who hid behind Trump’s toga in the primary are going to pay a price in November,” said veteran Republican consultant Rich Galen, a former aide to ex-U.S. House of Representatives Speaker Newt Gingrich.

“It’s the tyranny of small numbers,” Galen added. “In a primary in an off year, a few votes make a difference. But the 35 percent that are Trump voters will represent a small minority in the general election.”

Democrats need to pick up 23 seats in the House and two seats in the Senate in the Nov. 6 elections to regain control of those chambers, allowing them to block Trump’s agenda and possibly launch investigations or even impeachment of the president.

While Trump is popular with Republicans, opinion polls show his general approval hovering in the low 40s percent overall. Many key political battles of the midterms will be fought in swing House districts and big battleground states where loyalty to Trump is not necessarily a badge of honor.

“If those are the candidates we are nominating in swing districts - those who are pro-Trump first and foremost - that could cause problems in November,” Republican strategist Doug Heye said.

Trump’s power among Republicans in nominating primaries was evident when Sanford lost just hours after Trump issued a tweet criticizing him and endorsing his opponent.

The result is likely to be a cautionary tale for other Republicans considering questioning Trump’s personal or policy choices, even when the president strays from long-held party principles on issues like free trade and federal debt.

“It’s Trump’s party now. If you criticize the president, you will face the wrath of the Trump voter,” said Republican strategist John Feehery, a former congressional aide.

‘A CULTISH THING’

Republican Senator Bob Corker, who declined to run for re-election in conservative Tennessee after tangling with Trump, said on Wednesday the party was now in “a strange place,” and not a good one.

“It’s becoming a cultish thing, isn’t it? And it’s not a good place for any party to end up with a cult-like situation as it relates to a president that happens to be of, purportedly, of the same party,” Corker told reporters.

Corker, whose efforts to block Trump on tariffs have been rejected by congressional party leaders, is not the only Republican to step aside. Arizona Senator Jeff Flake, a harsh critic of Trump, is retiring at the end of the year.

In the House, more than 40 Republicans will not return next year, including Speaker Paul Ryan, with some citing the strain of partisan politics under Trump as a factor.

In Alabama last week, Republican U.S. Representative Roby was forced into a runoff by voters angered that she dropped her support for Trump during the 2016 campaign after the “Access Hollywood” video surfaced showing him bragging about assaulting women.

On Tuesday, Virginia Republicans rejected the party establishment to nominate pro-Trump Corey Stewart, an immigration hardliner and supporter of Confederate monuments whose aggressive campaign style recalls that of the president. He will challenge Democratic Senator Tim Kaine.

While Kaine was already expected to have an easy ride to re-election, Republicans fear Stewart’s harsh style could hurt other candidates by association, including endangered incumbent Representative Barbara Comstock, whose suburban Washington district is a top target for Democrats.

Comstock got a surprisingly low 61 percent of the vote in her primary against a little-known challenger who attacked her willingness to criticize Trump.

A brothel owner who calls himself “the Trump from Pahrump” even won the Republican nomination to the Nevada State Assembly.

But in South Carolina, Republican Governor Henry McMaster, an early Trump supporter, was forced into a runoff later this month with a political novice, businessman John Warren. The governor has faced questions over corruption in state government.

Trump’s mostly winning touch in Republican primaries has not translated to general elections.

He backed Roy Moore for Senate in Alabama and Ed Gillespie in the Virginia governor’s race last year, as well as Rick Saccone in a Pennsylvania special House election earlier this year. They all lost.

“Trump can flip a congressional primary given his strong support among Republican voters,” said Texas-based Republican strategist Matt Mackowiak. “We will see if he can flip U.S. Senate races in red states this fall.”