Former House speaker Newt Gingrich has won the South Carolina primary in a come-from-behind victory over former Massachusetts governor Mitt Romney.

Moments after several media outlets declared him the winner, Gingrich took to Twitter to thank his supporters.

"Thank you South Carolina! Help me deliver the knockout punch in Florida," Gingrich tweeted. He also included a link to his "Moneybomb" fundraising campaign.

Early results showed Gingrich winning 41 per cent of the vote, with Romney behind at 26 per cent. Socially conservative former Pennsylvania senator Rick Santorum was third with 18 per cent, followed by libertarian congressman Ron Paul in fourth with 13 per cent support.

The front-runner just days ago, Romney faced a late surge by Gingrich after a strong debate showing earlier in the week. Gingrich attacked the press after a question by the moderator about his personal life opened the proceedings.

Gingrich's ex-wife Marianne told ABC News earlier in the week that her now ex-husband had requested an "open marriage."

Gingrich also got a boost as Romney faced increasing demands to release his tax returns and questions about his record at private equity firm Bain Capital.

Romney was dealt another blow when the Iowa Republican Party declared Santorum the winner of the state caucuses held January 3. Romney had been previously declared the caucus winner in the squeaker, but the Iowa Republicans say Santorum had 34 more votes.

Add to that Texas Governor Rick Perry's endorsement of Gingrich as he suspended his campaign, and undecided South Carolina voters had a lot to chew on before they cast their ballots.

"A lot of info has been thrown at voters in South Carolina. It has been a lot to process," Reuters correspondent Sam Youngman told Â鶹ӰÊÓ Channel before polls closed at 7 p.m. EST.

After the winner was declared Saturday, Romney thanked supporters for their efforts and congratulated Gingrich on his victory.

"Now this race is going to be even more interesting," Romney told cheering supporters.

"This is a hard fight, because there's so much worth fighting for," he added later.

The stakes were high, as no Republican since 1980 has ever won the party's nomination without taking South Carolina.

The U.S. South is really the base of the Republican Party, where a lot of conservatives live. It serves as the centre of party enthusiasm, Washington Post reporter Philip Rucker told Â鶹ӰÊÓ Channel.

"It matters so much more about building momentum for your campaign," he said.

"So a win out of here, while it may only garner a few dozen delegates -- and you need 1,150 delegates to win the nomination -- it matters a lot about the perception of who's leading the race. Who can gather donations from supporters? And who can get voters to support them in other states down the road?"

Rucker said the "SuperPACs" -- political action committees with access to almost unlimited funds because they don't come from candidates' campaigns -- are behind "caustic" ads on the air in the state.

"But this is a state that has always had a tradition of dirty politics, so I don't think it's a surprise to see it play out this way down here."

The primary race heads next to Florida. The primary in the Sunshine State is Jan. 31, and while Romney has a clear lead in the polls there, Gingrich is expected to surge once again after Saturday's win.

Santorum declared Saturday evening that despite his showing in South Carolina, he will continue on to Florida.