Washington CNN  — 

President Donald Trump took credit Wednesday for state Rep. Katie Arrington’s projected win over incumbent Rep. Mark Sanford in the South Carolina Republican primary.

“My political representatives didn’t want me to get involved in the Mark Sanford primary thinking that Sanford would easily win - but with a few hours left I felt that Katie was such a good candidate, and Sanford was so bad, I had to give it a shot,” Trump wrote on Twitter, while also congratulating Arrington.

Trump had endorsed Arrington in a tweet hours before the polls in South Carolina closed Tuesday and also attacked Sanford for being “very unhelpful to me in my campaign to MAGA.”

Sanford has publicly criticized Trump, at one point saying Trump had “fanned the flames of intolerance.” On Tuesday, he noted that it’s “fairly unusual” for a president to weigh in as Trump did and saying he’s “neither for nor against Trump,” but instead bases his decisions and comments on his political values.

CNN’s Eric Bradner contributed to this report.