With 98% of the vote counted, USA media called the race for state representative Katie Arrington, who led Sanford by 50.5% to 46.5%.
Arrington, a political newcomer who has held her seat since 2016, spent the campaign blasting Sanford - who had never lost an election - over his lack of loyalty to Trump and attacked him in ads for a much-publicized extra-marital affair with an Argentinian journalist.
Sanford has said in several interviews in recent months that the tenor of his town halls and other campaign events in his coastal 1st District had shifted, with voters using expletives and saying if Trump can say anything he wants, they can, too.
President Trump's reference to Argentina was a dig at Sanford's 2009 affair scandal during the time he was governor of SC, when he disappeared for several days on a secret trip to Buenos Aires to visit his mistress.
U.S. Congressman Mark Sanford will not return to Washington for another term in office.
McMaster, an early supporter of the president's 2016 campaign, had Trump's full endorsement, marked by a weekend tweet. Alabama Rep. Martha Roby was forced into a runoff.
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". And she reminded them who she thinks leads them: "We are the party of President Donald J. Trump".
Despite the scandal over the affair, he completed his second term as governor, and voters sent him to Congress two years later.
Elsewhere on primary night, another Trump candidate picked up a major victory in Tuesday's Virginia Senate primary as Corey Stewart picked up the state's Republican nomination and will now take on the incumbent - former vice presidential nominee Sen.
"You don't fire the coach and hire a rookie", McMaster said in a speech after results came in, touted business investments under his leadership and the Trump endorsement. Nevada, North Dakota, Maine and Virginia also chose candidates for the midterm election on November 6, when Democrats hope to capture a majority of the U.S. Congress.
'She is tough on crime and will continue our fight to lower taxes.
State and national Republicans admitted there's virtually no chance Stewart will defeat Democratic Sen. If no candidate wins an outright majority, ballot-counters eliminate the candidate with the fewest first-choice votes and redistribute that person's support to the runners-up - and so on until one candidate comes out on top. One wrong turn - or in Sanford's case, many - and they could face the wrath of a president who is quick to attack detractors as enemies, even in his own party. He is better of in Argentina.
Dimitri Cherny is also running.
"But I don't know if the outcome would have been different in the long run, because of the larger tide I was up against", he added.