In the end, it wasn’t the Appalachian Trail that brought down Mark Sanford. It was President Donald Trump. 
 
 The South Carolina congressman’s stunning defeat in Tuesday’s Republican primary effectively ended the turbulent two-decade career of a political icon who once harbored presidential aspirations. State Rep. Katie Arrington defeated Sanford 50.6 percent to 46.5 percent. 
 
 Story Continued Below 
 
 From his time as a congressman in the 1990s, to his eight-year governorship, to his unexpected House comeback that followed, Sanford had long established himself as a figure who cut against the grain — the rare politician who loved to break with his own party. Yet in taking on Trump, his friends and political allies say, he took it a step too far. 
 
 His defeat is bound to raise fears among Republicans about the political perils of crossing a president who remains deeply popular with GOP voters. In recent days, Sanford himself had expressed concern that a loss in the primary would discourage what dwindling GOP dissent against the White House remains. 
 
 At the heart of Sanford’s downfall was a fundamental miscalculation, those close to him said: that he could go after the Republican president — vigorously, and sometimes in deeply personal ways — and get away with it. 
 
 “Mark had a long and storied career, he was a very famous and successful politician. But he didn’t read the tea leaves right, and that came back to haunt him,” said former state Rep. Chip Limehouse, who hails from a prominent Charleston family and has known Sanford for years. “Mark misjudged it, attacking Trump. That’s what killed him.” 
 
 The South Carolina Republican, 58, was nothing if not durable. After entering office in the 1994 Republican revolution, Sanford weathered a series of political storms. 
 
 As a congressman in 1999, he and then-Oklahoma Rep. Tom Coburn staged a bold public protest against their own Republican leaders by shutting down floor debate on an appropriations bill. As governor, he repeatedly collided with GOP members of the state Legislature — at one time, bringing a pair of pigs to the House chamber to protest deficit spending in the state budget. When it was revealed in 2009 that he’d had an affair with an Argentine woman, while he had claimed to be hiking the Appalachian Trail, he ignored GOP calls for him to step down. 
 
 And after the National Republican Congressional Committee cut off support for his 2013 congressional campaign, he plowed ahead and defeated his Democratic opponent. 
 
 Morning Score newsletter Your guide to the permanent campaign — weekday mornings, in your inbox. Email Sign Up By signing up you agree to receive email newsletters or alerts from POLITICO. You can unsubscribe at any time. 
 
 In each case, Sanford found a way to hang on. Yet as the 2018 campaign kicked into high gear, Sanford, who’d never lost a political race, found himself under mounting pressure. 
 
 At issue: His relentless criticism of the president. 
 
 Arrington, Sanford’s rival, cast the congressman as a disloyal Never Trumper. She aired commercials highlighting cable news clips spotlighting negative comments that he’d made, including one instance in which he said Trump should “just shut up” and stop spending so much time paying attention to critics. Arrington portrayed the incumbent as an obstructionist who was hell-bent on getting in the president’s way. 
 
 “He made a calculation in the post-Trump election that he was going to stand on principle. … But there’s an expectation out there, at least in South Carolina’s 1st District, that you have to show deference to the president,” said Scott English, a former Sanford chief of staff who remains close with the congressman. “In this race, the ideas didn’t matter nearly as much as whether he’d been sufficiently loyal to the president in the eyes of voters.” 
 
 Trump himself stayed out of the race until just hours before the polls closed on Tuesday, when he sent out a surprise tweet calling for the congressman’s defeat. Arrington’s campaign rushed out a robocall to 50,000 homes highlighting the president’s last-minute endorsement. 
 
 Other South Carolina pols say that while Sanford’s opposition to Trump was his undoing, other factors were at play. Some people close to the congressman believe that voters never really got over his affair, which destroyed his national ambitions. Others say there was general exhaustion with a politician who’s been around since the mid-1990s and that voters were ready for someone new like Arrington, a political newcomer serving her first term in the state Legislature. 
 
 In what was perhaps an early sign that his political strength was abating, Sanford received just 55 percent of the vote in his 2016 primary, against an opponent who spent little. 
 
 Others say Sanford simply failed to run an effective race this year, allowing himself to be outworked. Sanford’s lethargic reelection bid was a lightly staffed shoestring affair. Many of the advisers who guided his gubernatorial and congressional campaigns were not involved. 
 
 After realizing he was in trouble, the ever-frugal congressman, who hadn’t spent money on TV ads in five years, rushed out a slate of commercials. Some went after Arrington directly. Others tried to make the case that Sanford had cooperated with the White House. 
 
 While Arrington relentlessly cast Sanford as anti-Trump, his backers worried, Sanford struggled to find a coherent message. 
 
 “She got up on TV early and defined the message, and he let her define him,” said state Rep. Nancy Mace, a Sanford supporter. 
 
 In the days leading up to the primary, Sanford was hesitant about his prospects. During an interview with POLITICO on Saturday evening in Mount Pleasant, he repeatedly refused to assess his prospects. And when a constituent approached him to ask what polls showed, he paused. 
 
 “They show different things,” he said. 
 
 Behind the scenes, Sanford’s allies worried that he had a ceiling of support — and that by going after his disloyalty to the president, Arrington had found a way to surpass the battle-hardened incumbent. 
 
 His political career appears to be over. 
 
 “I don’t see any future for him from here [in politics]. This is basically it,” said English, who added that Sanford could still engage in conservative causes from outside elected office. “This is the last ride of Mark Sanford. It’s been a fascinating ride.” 
 
 ||||| These crawls are part of an effort to archive pages as they are created and archive the pages that they refer to. That way, as the pages that are referenced are changed or taken from the web, a link to the version that was live when the page was written will be preserved.Then the Internet Archive hopes that references to these archived pages will be put in place of a link that would be otherwise be broken, or a companion link to allow people to see what was originally intended by a page's authors.The goal is to fix all broken links on the web . Crawls of supported "No More 404" sites. ||||| 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!
– Rep. Mark Sanford can now spend as much time as he wants hiking the Appalachian Trail: The congressman and South Carolina governor lost his Republican primary Tuesday, hours after a very critical tweet from President Trump, Politico reports. "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," Trump said, referring to Sanford's infamous 2009 affair. "I fully endorse Katie Arrington for Congress in SC, a state I love," Trump said. Analysts say the 58-year-old Sanford, whose political career is now probably over, criticized President Trump more often than South Carolina voters considered acceptable. "We are the party of President Donald J. Trump," Arrington told supporters after winning just over half the vote. Sanford, who has long seen himself as a political outsider, was unrepentant after the defeat Tuesday, which was his first-ever election loss, CBS reports. "I stand by every one of those decisions to disagree with the president," said the Republican, who was re-elected to his old House seat in 2013 despite the national GOP withdrawing support. In other races, Nevada's Sen. Dean Heller cruised to victory in the GOP primary, the Washington Post reports. He had been expected to face a tough challenge from activist Danny Tarkanian, but Trump persuaded Tarkanian to seek a congressional nomination instead, which he won Tuesday. In North Dakota, Rep. Kevin Cramer won the GOP primary for a Senate race. He will face Democratic Sen. Heidi Heitkamp this fall in a race that could determine control of the chamber.