Media captionRick Perry: "I know when it's time to make a strategic retreat"

The Republican presidential race has been shaken up after Texas Governor Rick Perry quit and endorsed former House Speaker Newt Gingrich.

But the potential boost to the Gingrich campaign was countered by his ex-wife's claims that he wanted an open marriage.

On a busy campaign day it emerged that front-runner Mitt Romney had not won Iowa's caucuses, as initially declared, because of a mix-up on the vote count.

The four remaining contenders face a crunch TV debate on Thursday.

Ahead of the debate a flurry of opinion polls indicated that a resurgent Mr Gingrich may be closing in on Mr Romney's lead.

The long-time front-runner has come under pressure to disclose his tax returns as his business success and personal fortune remains a divisive campaign issue.

Mr Romney, a former governor of Massachusetts, Mr Gingrich, a former House speaker, veteran Texas Congressman Ron Paul and a former Pennsylvania Senator Rick Santorum will compete in a potentially crucial primary election in South Carolina on Saturday.

'Newt's not perfect'

Mr Romney is the front-runner in the state-by-state race for the Republican Party's nomination to challenge Democratic President Barack Obama for the White House this November.

Rick Perry's star faded long ago. Recent opinion polls in South Carolina put him somewhere between 2% and 5%. He can't bequeath those votes, only urge supporters to vote for Mr Gingrich. But it is likely almost all of his would-be supporters will vote for a candidate who is not Mitt Romney. The narrowing of the field concentrates minds and makes it slightly easier for conservatives to come together behind an alternative.

The interview with Newt Gingrich's ex-wife far outweighs this bit of good news for the former Speaker. There is no doubt hearing more details of his infidelities will disturb Christian conservatives who are big in this state. But central to their faith is the ideal of forgiveness and redemption. They may give Mr Gingrich a chance despite their doubts.

When Mr Perry entered the race in August, he briefly shot to the front of the pack before gaffes and poor debate performances set him back.

The Texas governor told supporters in South Carolina on Thursday: "I've come to the conclusion that there is no viable path forward for me in this 2012 campaign.

She claims he conducted the extramarital affair in the bedroom of their Washington apartment while she was away, and would call her at night to say he loved her, while sharing the bed with his then lover.

Though she has spoken publicly about their 18-year marriage before, the interview could hurt Mr Gingrich in South Carolina, where religious and cultural conservatives are a big part of the Republican base.

Mr Gingrich defended himself on the campaign trail in that state on Thursday, saying: "I have been very open about the mistakes I've made. I am 68 years old. I am a grandfather."

Mr Perry had briefly reconsidered his campaign after finishing fifth in Iowa's first-in-the-nation nominating contest this month, but ploughed on.

He skipped the moderate New England state of New Hampshire to focus on South Carolina. But his message failed to take off even in that conservative southern state.

His departure follows on the heels of former Utah Governor Jon Huntsman, Minnesota Congresswoman Michele Bachmann and last month, Georgia businessman Herman Cain.

Mr Perry had faced calls in recent days to stand aside as rivals warned the conservative vote would fracture across the candidates, ultimately benefiting Mr Romney.

Missing Iowa votes

Mr Romney's Mormon faith and political record as governor of the liberal state of Massachusetts is viewed with suspicion by some conservative Republicans.

US media react to Perry's exit

Alex Koppelman writes in the New Yorker that Rick Perry's exit from the race is a positive move for the country. "He never seemed to add anything of substance to the debates, but he did inject some levity, with his embarrassing mistakes and his constant striving for the lowest common denominator."

While at The Atlantic, Molly Ball says Mr Perry's withdrawal is a good thing for Newt Gingrich. "Perry's forthcoming endorsement is yet another positive sign for the former House speaker, who's already basking in the glow of surging South Carolina poll numbers and positive debate buzz."

But Mr Perry's endorsement of Mr Gingrich won't be enough to secure him the nomination, writes Ruth Marcus for the Washington Post: "Gingrich's terrific debate performances notwithstanding, his record is too studded with land mines and his personality too undisciplined for him to take the nomination from Romney."

Also on Thursday, the final results of the Iowa caucuses were certified as a split decision between Mr Romney and Christian conservative Mr Santorum because of missing data.

Mr Romney had initially been declared the winner of the 3 January nominating contest by eight votes.

But the final count shows Mr Santorum ahead by 34 votes, although no winner has been declared because the results from eight precincts are missing.

According to the certified vote totals, Mr Santorum won 29,839 votes while Mr Romney had 29,805. Mr Paul kept his third-place finish, with 26,036 ballots.

Iowa Republican Party chairman Matt Strawn announced the results at a news conference.

The Romney campaign called the outcome a "virtual tie", while the Santorum campaign said it changed the narrative of the race.