US Rep. Mark Sanford (R) of South Carolina, a vocal critic of President Trump, lost a Republican congressional primary in South Carolina after Mr. Trump urged voters to punish Representative Sanford's disloyalty by tossing him from office.

A few hours before polls closed on Tuesday, Trump tweeted that Sanford was "nothing but trouble" and "very unhelpful to me." He backed Sanford's pro-Trump challenger, state legislator Katie Arrington, for November's congressional elections.

Representative Arrington, who made a campaign issue of Sanford's criticism of Trump, won 50.6 percent of the vote to Sanford's 46.5 percent with almost all ballots counted. That just crossed the 50 percent threshold to avoid a runoff later this month between the top two contenders.

The South Carolina race highlighted primary voting in five states on Tuesday. Nevada, North Dakota, Maine, and Virginia also chose candidates for the midterm election on Nov. 6, when Democrats hope to capture a majority of the US Congress.

The upset of Sanford, a member of the conservative House Freedom Caucus, was the latest sign of Trump's firm grip on the Republican Party. The onetime insurgent has made allegiance to his leadership a litmus test in many Republican races.

Sanford had been critical of Trump at times, saying he "fanned the flames" of intolerance and decrying his disregard for facts. But during the campaign, he ran ads saying how often he voted with the president.

That was not enough for Trump, who also mocked Sanford with a reference to a 2009 scandal when the then governor disappeared for days before surfacing to say he was "hiking the Appalachian Trail." Later, Sanford admitted he was involved in an extramarital affair in Argentina.

Trump, who issued his tweet as he returned from his summit with North Korean leader Kim Jong un, said Sanford "is better off in Argentina." On Wednesday, he congratulated Arrington in another tweet, saying his advisers had earlier told him to stay out of the race but that he "had to give it a shot."

Republican Rep. Justin Amash, Sanford's fellow conservative and House Freedom Caucus member, fired back at Trump after his attack on Sanford.

"Unlike you, Mark has shown humility in his role and a desire to be a better man than he was the day before," Representative Amash said on Twitter.

Sanford is the second Republican member of Congress to lose in a nominating contest this year, following Robert Pittenger's loss in North Carolina last month. But Sanford's South Carolina district is considered a safe Republican seat, meaning the outcome is unlikely to play a role in November's battle for control of the House.

Democrats target Comstock

In Virginia, a state legislator favored by the Virginia Democratic Party establishment won a crowded battle for the right to challenge one of the most endangered congressional Republicans in November's elections.

Democrat Jennifer Wexton won a six-way primary race in a suburban Washington district and will take on Republican Barbara Comstock, one of the Democrats' top targets in their push to pick up the 23 seats they need to claim a majority in the US House of Representatives.

Ms. Comstock's district, home to many federal government workers, has drifted left in recent years. Democrat Hillary Clinton carried it over Trump by 10 percentage points in the 2016 presidential election.

Corey Stewart, a combative conservative Republican and immigration hardliner who nearly upset Ed Gillespie for the party's gubernatorial nomination last year, won the right to face Democratic Sen. Tim Kaine, the 2016 vice presidential candidate, in November's US Senate election in November.

Trump weighed in on Mr. Stewart's victory on Wednesday, resurrecting his 2016 attacks against Senator Kaine and saying in a post on Twitter that Stewart had "a major chance of winning."

In North Dakota and Nevada, voters set the stage for two of the most competitive US Senate races in November, when Democrats must pick up two seats to capture a Senate majority.

In North Dakota, Republican Rep. Kevin Cramer easily won the nomination to challenge Democratic Sen. Heidi Heitkamp. In the swing state of Nevada, Democratic Rep. Jacky Rosen sailed to the nomination to face vulnerable Republican Sen. Dean Heller.

Maine voters were the nation's first to use a new voting system in a statewide election letting them rank candidates by preference rather than choosing just one.

Under the system, now used in a few local jurisdictions, the election is over if one candidate wins a majority. But if not, the lowest vote-getter is eliminated, with their votes reallocated until one contender gains a majority.

The use of the system angered outgoing Republican Gov. Paul LePage, who told a television station it was "the most horrific thing in the world." He said he might not certify the election results.

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

Maine Secretary of State Matt Dunlap said the election results would be binding anyway, the Portland Press Herald said.

This story was reported by Reuters.