A primary challenger backed by President Donald Trump successfully unseated incumbent Rep. Mark Sanford (R-S.C.) tonight just hours after Trump took to Twitter to attack Sanford for—of all things—the congressman's marital infidelities.

First-term state Rep. Katie Arrington (R-Dorchester) defeated Sanford, earning more than 51 percent of the vote to Sanford's 46 percent. She will face Democratic challenger Joe Cunningham in the heavily Republican district this November. Meanwhile, Sanford's defeat means Congress will lose an advocate for limited government and individual liberty at the end of the current term.

In an interview with Politico last weekend, Sanford suggested that a loss in his re-election bid could cause other Republicans to think twice before speaking out against the Trump administration. Now that he's lost, his words also serve as a call for his fellow anti-Trump GOPers to keep fighting the good fight.

"I think it's entirely appropriate to say 'I agree' when I agree and 'I disagree' when I disagree," Sanford told Politico's Alex Isenstadt. "That's the American way. That's what our entire political system is based on, is the fact that we can have dissent."

Taking down an incumbent is no easy feat in American politics, but this race was really a referendum on the relative strength of the anti-Trump contingent in the Republican Party as it struggles to hold off the #MAGA cult of personality.

Sanford's dissent to Trump's takeover of the GOP dates back nearly two years. In July 2016, shortly after wrapping up the Republican nomination and hoping to unify the party before the convention, Trump paid a high profile visit to congressional Republicans on Capitol Hill. Sanford came away from a closed-door meeting less than impressed by Trump's grasp of the U.S. Constitution.

"I wasn't particularly impressed," Sanford told The Washington Post at the time. "It was the normal stream of consciousness that's long on hyperbole and short on facts. At one point, somebody asked about Article I powers: What will you do to protect them? I think his response was, 'I want to protect Article I, Article II, Article XII,' going down the list. There is no Article XII."

Since then, Sanford has accused Trump of fanning "the flames of intolerance," criticized Trump's use of the word "shit-hole" to describe some third world countries, and most recently called the president's plan to impose tariffs on steel and aluminum imports "an experiment with stupidity." He's also criticized Speaker of the House Paul Ryan (R-Wisc.) for not taking a hard enough line against the Trump White House.

Trump appears to have taken notice. As voters were heading to the polls Tuesday, the president took a shot at the incumbent congressman.

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! — Donald J. Trump (@realDonaldTrump) June 12, 2018

Yes, that reference to Argentina is the thrice-wedded president (who may have had an affair with a porn star) accusing Sanford of being bad at marriage, apparently without a hint of irony.

It's true that Sanford's six-day disappearance during July 2009—when he was supposedly hiking a portion of the Appalachian Trail, but was actually having an extramarital affair with an Argentine woman, María Belén Chapur—changed the course of his political career. An effort was made to impeach Sanford, but South Carolina lawmakers ended up merely issuing a "rebuke" of the governor instead. Sanford finished his term, then got elected to Congress in 2013 (he had previously represented the same district from 1995 through 2001, when he stepped down to honor a promise to serve only three terms).

Prior to La Affaire Argentine, Sanford was regarded as a possible White House contender. Following Ron Paul's 2008 dark horse presidential run, he and then-governor of New Mexico Gary Johnson (along with, of course, Rand Paul) were often identified as the heirs apparent to the libertarian wing of the GOP.

"They'll say it as if it's an evil word—like 'you're a communist' or something," Sanford said in 2009 when he was labeled a "libertarian" by Sen. Lindsey Graham (R-S,C), whom no one would confuse for a libertarian. "I wear it as a badge of honor, because I do love, believe in, and want to support liberty."

It is fitting, perhaps, that the Republican Party's turn towards Trump's economic nationalism has coincided with Johnson departing the party to become a Libertarian and Sanford being tossed from its ranks.

Will there be a third act for Sanford? One can hope. Whatever you may think of his personal foibles, he's been a consistently principled voice for liberty and limited government. He opposes bailouts, loves Atlas Shrugged, and disdains political tribalism. And in the age of Trump, a history of adultery is hardly political suicide anymore.