WASHINGTON — Mark Sanford blew up his marriage and became a national laughingstock when he sneaked off his job as South Carolina governor for a tryst with his Argentine lover.

After he forsook his presidential ambitions and spent time in political purgatory, voters forgave Sanford’s trespass and, in 2013, elected him their representative in Congress.

But on Tuesday, Sanford was tossed from office by his Republican constituents for committing a far graver sin: criticizing President Donald Trump.

With his bulldozing personality, Trump has transformed the GOP from a party of anti-communist cold warriors to one that coos over North Korea’s communist dictator, from a champion of free trade to an instigator of trade wars.

And woe to those within the party who challenge his direction or judgment.

“If you’re a Republican member of Congress who wants to speak out against Trump, you have a couple of choices,” said David Wasserman, who handicaps House races nationwide for the nonpartisan Cook Political Report. “Retire or lose your next primary.”

The Trump takeover, which seemed shaky after his favored candidates in a 2017 Alabama Senate race faltered and fell, now seems complete.

A candidate elected over the strong protestations of the Republican Party establishment, who failed to win the popular vote and has consistently earned the lowest approval ratings of any president at this stage in his term, has emerged, at least so far as the GOP is concerned, as its kingmaker supreme.

A well-timed Twitter post even helped lift the nondescript Republican John Cox into the gubernatorial runoff against Democratic Lt. Gov. Gavin Newsom in deep-blue California.

Part of Trump’s strengthening grip on the party may reflect passage of a sweeping tax cut, a page from Republican gospel, which reassured the faithful that Trump could deliver on some of their priorities.

Part may also stem from Trump’s success in convincing Republicans he is under siege by what he describes as a politically motivated “witch hunt” into Russia’s interference in the 2016 campaign.

Sanford faced an opponent, state lawmaker Katie Arrington, who made the South Carolina contest an explicit referendum on loyalty to the president. She labeled Sanford an obstructionist — though he voted the overwhelming majority of the time for the president’s agenda — and running a TV ad splicing together Sanford’s assorted criticisms of Trump.

“I respect the office of the president,” Arrington said during an election-eve debate with her opponent. “You can’t have a seat at the table in the Oval Office because you have offended the president numerous times.”

In another ad, she took a veiled swipe at Sanford’s affair and his phony alibi — that he was off by himself, hiking the Appalachian Trail — when he was out of the country with his lover. “Bless his heart,” she said, “but it’s time for Mark Sanford to take a hike — for real this time.”

Hours before the polls closed Tuesday, Trump weighed in from Air Force One with a taunting tweet:

“Mark Sanford has been very unhelpful to me in my campaign to MAGA. He is MIA and nothing but trouble. He is better off in Argentina. I fully endorse Katie Arrington for Congress in SC, a state I love. She is tough on crime and will continue our fight to lower taxes. VOTE Katie!”

Arrington scratched out a narrow win.

The president wasn’t golden in every race he touched. In South Carolina’s gubernatorial primary, incumbent Henry McMaster, one of Trump’s earliest 2016 supporters, was forced into a runoff despite Trump’s endorsement. But the president’s electoral impact Tuesday was undeniable and concerning to those who fear the GOP has surrendered its core principles and become “a cult of personality,” as Eric Erickson, a conservative talk radio host and prominent political blogger, put it in an election night tweet.

The most recent weekly Gallup survey put Trump’s approval at 90 percent among Republicans, the peak of his presidency and a mark approaching George W. Bush’s high-water standing in the months after the Sept. 11 terrorist attack.

The GOP is not as divided as Trump critics would like to portray, said John Feehery, a former aide to the Republican House leadership. Say what they will, the party rank-and-file are united behind Trump.

mark.baraback@latimes.com