Media playback is unsupported on your device Media caption Newt Gingrich: "We can rebuild the America that we love"

Newt Gingrich has convincingly beaten Mitt Romney in South Carolina's primary election, the latest leg in the battle to be the Republican candidate in November's US presidential poll.

With almost all votes counted, Mr Gingrich had 40% to Mr Romney's 28%.

Mr Romney was widely seen as the frontrunner, but the latest outcome is set to turn the race into a long, hard-fought campaign, correspondents say.

The South Carolina victor has won the nomination in each election since 1980.

Other Republican hopefuls, former Pennsylvania senator Rick Santorum and Texas representative Ron Paul, were trailing badly with 17% and 13% respectively.

Knockout punch plea

US networks called the vote in the former House speaker's favour shortly after polls closed at 19:00 local time on Saturday (00:00 GMT Sunday), as exit polls predicted a wide margin of victory for Mr Gingrich.

South Carolina primary results Source: SC State Election Commission

See the latest delegate count Gingrich 40% Romney 28% Santorum 17% Paul 13% 2,116 of 2,129 precincts reporting

BBC North America editor Mark Mardell, in South Carolina, says a Gingrich win is important, because all along the story of this race has been the search by conservatives for an alternative to Mitt Romney.

It is just possible they have settled on Mr Gingrich, and at the very least such a result will puncture the sense that eventually Mr Romney will triumph, our correspondent adds.

Shortly after the vote, Mr Gingrich wrote on Twitter: "Thank you South Carolina! Help me deliver the knockout punch in Florida," referring to the next nominating contest on 31 January.

The contest for that state is now seen as crucial, being a major battleground state in the US general election, with a diverse electorate and where a lot of money will be spent campaigning.

Several hours later, Mr Gingrich appeared at his campaign headquarters in the state capital Columbia - to wild cheers from supporters.

"We don't have the kind of money that at least one of the candidates has, but we do have ideas and we do have people and we have proved here in South Carolina that people power with the right ideas beats big money and with your help we are going to prove it again in Florida," he said.

Earlier, Mr Romney told his supporters they were "three contests into a long primary season" and vowed to fight for every vote in every state.

Analysis The story of the Republican race for months has been the search for an anti-Mitt, a non-Romney, a single candidate who conservatives could unite around. It is now possible, but by no means inevitable, that Gingrich has the momentum to become that candidate. Certainly he has burst Mitt's bubble, punctured the sense that he is the inevitable winner. Some question whether Gingrich has the money to go the course. Others say he doesn't have the organization to win in other states. A bigger question might be whether he has the discipline not to self destruct. Gingrich bursts Romney's bubble In pictures: Gingrich wins

Meanwhile, Mr Santorum pledged to fight on, saying: "It's a wide open race".

Mr Gingrich has captured the headlines in recent days, batting off a potentially damaging interview from an ex-wife, in which she said he had wanted an "open marriage".

Mr Gingrich's victory means that three different candidates have won the first three nominating state-by-state contests - Mr Santorum narrowly beat Mr Romney in the Iowa caucus, while Mr Romney claimed the New Hampshire primary.

All contenders agree that this will now be an endurance race, rather than the quick sprint which Team Romney had hoped for, the BBC's Steve Kingstone says.

Mr Romney must now adapt his strategy, and come up with a more decisive riposte to those who criticise his personal wealth and career record as a venture capitalist, our correspondent says.

Expect a brutal media war in Florida, he adds.

Mr Romney set the tone in his post-defeat address, accusing Newt Gingrich of aligning himself with President Obama in a "frontal assault on free enterprise". For his part, Gingrich will counter that the "Massachusetts moderate" is the real Obama clone.

Primaries and caucuses will be held in every US state over the next few months to pick a Republican nominee before the eventual winner is anointed at the party convention in August to take on Democratic President Barack Obama in November.