NORTH CHARLESTON, S.C. - The race for the Republican presidential nomination took several twists and turns Thursday as Rick Perry dropped out, Newt Gingrich faced stunning allegations from an ex-wife and Mitt Romney struggled to maintain a shaky front-runner's standing.

An aggressive evening debate in the critical state of South Carolina, site of the next primary vote, capped the bewildering day.

Recent polls, coupled with Perry's endorsement, suggested Gingrich was the candidate with the momentum and Romney the one struggling to validate his standing as front-runner. Whatever else the impact, the day's events reduced the number of contenders vying to emerge as Romney's principal conservative alternative.

Former Sen. Rick Santorum played aggressor for much of the night, struggling to inject himself into what seemed increasingly like a two-way race with less than 48 hours remaining until the South Carolina polls open on Saturday. He accused the surging Gingrich and frontrunner Romney of agreeing with the left when it came to health care. Both men rejected the allegations.

The debate began a few hours after first word that Romney's narrow Iowa caucus victory was actually a narrow loss, then had been stung by Perry's endorsement of Gingrich.

Gingrich, in turn, was accused by an ex-wife of seeking an open marriage so he could keep his mistress.

"Newt's not perfect, but who among us is," said Perry, abruptly quitting the race just before the first-in-the-South primary.

His decision to end a once-promising candidacy left Romney, Gingrich, Santorum and Texas Rep. Ron Paul the remaining contenders in the race to pick a Republican to challenge Democratic President Barack Obama this November.

Hours after Perry exited one stage, the four remaining contenders walked onto another for a final pre-primary debate.

Gingrich angrily denounced the news media for putting his ex-wife front and centre just before South Carolina votes, but Santorum, Romney and Paul steered well clear of the controversy.

All four remaining Republican candidates lustily attacked Obama, while Santorum in particular sought to raise his own profile.

Introduced to the audience, he mentioned his change of fortunes in Iowa, where an eight-vote defeat in kickoff caucuses was now a 34-vote advantage -- though the Iowa Republican Party did not declare a winner.

Santorum jabbed at both Gingrich and Romney, but seemed to focus more attention on the former. If Gingrich is the party nominee, he said, "you sort of have that worrisome moment that something's going to pop. And we don't need that in a nominee."

Romney, the former Massachusetts governor, had other challenges in a state where unemployment approaches 10 per cent. He adamantly refused to explain why some of his millions were invested in the Cayman Islands, how much was there or whether any other funds were held offshore.

Gingrich grappled with problems of a different, possibly even more crippling sort in a state where more than half the Republican electorate is evangelical Christian.

In an interview scheduled to air on ABC News, Marianne Gingrich said her ex-husband had wanted an "open marriage" so he could have both a wife and a mistress. She said Gingrich conducted an affair with Callista Bistek -- his current wife -- "in my bedroom in our apartment in Washington" while she was elsewhere.

"He was asking to have an open marriage and I refused. That is not a marriage," she said in excerpts released by the network in advance of the program.

Asked about it during the debate, Gingrich repeatedly criticized the media, then briefly addressed the accusation. "The story is false," he said, with no elaboration.

Santorum, whose fortunes have ebbed since what appeared to be a narrow loss in Iowa, pronounced himself the winner there after all when state party officials in Des Moines announced he had finished 34 votes ahead of Romney instead of eight behind. Romney went on to easily win the New Hampshire primary.

"There have been two contests. We won one," he said, and he proceeded to ridicule Romney and Gingrich as weak challengers to Obama. "How can you differentiate ourselves on the major issues of the day if we nominate tweedledum and tweedledee instead of someone who stood up and said, 'No'?" he said to one audience, referring to his opposition to a requirement to purchase health care coverage.

Perry's exit marked the end of a campaign that began with soaring expectations but quickly faded. He shot to the head of the public opinion polls when he announced his candidacy last summer, but a string of poor debate performances soon led to a decline in support.