South Carolina Rep. Mark SanfordMarshall (Mark) Clement SanfordTrump endorses Gaetz in reelection bid GOP candidate hurt in car crash: 'My children call me the Terminator. You just can't break me' GOP candidate vows to continue campaign in first public comments since car crash MORE (S.C.), days after his loss to a pro-Trump candidate in a GOP primary, offered defiant words on "Morning Joe," saying he will always pledge allegiance to the flag rather than a president.

Sanford blamed his loss on Trump, saying his election came down to people questioning whether he was for or against Trump.

"We swear an allegiance to the Constitution and we pledge allegiance to the flag and what was weird about this race that I've never experienced before in any race I've been a part of was an allegiance question where people say are you for or against the president," Sanford said during the MSNBC interview on Thursday.

"I've never before had a question of allegiance to a person, rather than allegiance to the flag and Constitution and to a degree that's what this race came down to," he said.

Sanford, the former governor of South Carolina who has served in the House since 2013, was defeated by South Carolina state Rep. Katie Arrington in Tuesday's primary.

Arrington criticized Sanford, a frequent critic of Trump's, for being insufficiently loyal to the White House. Trump tweeted his support for Arrington and took a shot at Sanford on primary day, saying the former South Carolina governor was better off in Argentina.

"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 tweeted. "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!"

Trump was referencing a trip the then-governor had taken to Argentina in 2009 to visit a woman with whom he was having an affair. He later admitted to the affair and the trip.

The incident was widely mocked after aides initially said Sanford could not be reached for comment because he was hiking on the Appalachian trail. 

Though it’s unclear how much impact the president’s last-minute endorsement made in the final stretch of the primary election, Sanford said Trump’s tweet hurt him, adding that the president’s "if you offend me, I'm coming back to get you"-attitude was "a little outside the norm.” 

Pledging “allegiance to Donald TrumpDonald John TrumpSasse: Trump shouldn't dignify Putin with Helsinki summit Top LGBT group projects message onto Presidential Palace in Helsinki ahead of Trump-Putin summit Hillary Clinton to Trump ahead of Putin summit: 'Do you know which team you play for?' MORE," Sanford warned Republicans, could be "a mistake on a soul level." 

"There are always trade offs in politics … but I think everybody's has got to answer that question for themselves," Sanford concluded.

-Updated June 14 at 1:11 p.m.