Media playback is unsupported on your device Media caption Rick 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.

"Therefore today I am suspending my campaign and endorsing Newt Gingrich."

He called Mr Gingrich "a conservative visionary who can transform our country", adding: "Newt is not perfect, but who among us is?"

Moments later, Mr Gingrich welcomed the endorsement.

Recent opinion polls have shown Mr Gingrich cutting into Mr Romney's lead, although he still trails Romney by about 10 percentage points.

But the former House Speaker's ex-wife, Marianne, has made potentially damaging claims in a TV interview to be broadcast in full on Thursday evening.

In an excerpt of her remarks on ABC News' Nightline programme, the former Mrs Gingrich says her ex-husband wanted her to share him with Callista Bisek, the woman who would become his third wife.

Perry: Where did it all go wrong? 1 Oct: Raises eyebrows after saying he would consider sending US troops into Mexico to fight drug war

Raises eyebrows after saying he would consider sending US troops into Mexico to fight drug war 28 Oct: An unusually animated speech by Perry in New Hampshire prompts him to deny speculation he was drunk or on medication

An unusually animated speech by Perry in New Hampshire prompts him to deny speculation he was drunk or on medication 10 Nov: In a debate, Perry can't remember the name of a third government department he would eliminate if elected

In a debate, Perry can't remember the name of a third government department he would eliminate if elected 29 Nov: Mistakenly refers to the minimum voting age as 21 (it's 18)

Mistakenly refers to the minimum voting age as 21 (it's 18) 6 Dec: Is fiercely criticised for a campaign ad attacking gays in the military and claiming children can't celebrate Christmas

Is fiercely criticised for a campaign ad attacking gays in the military and claiming children can't celebrate Christmas 8 Dec: Corrects himself after saying US had been at war in Iran, rather than Iraq

Corrects himself after saying US had been at war in Iran, rather than Iraq 9 Dec: Says eight justices sit on the Supreme Court (the number is nine)

Says eight justices sit on the Supreme Court (the number is nine) 3 Jan: Reconsiders campaign after flop in Iowa, only to change his mind, distributing a photo of himself in athletic attire, giving a thumb-up

Reconsiders campaign after flop in Iowa, only to change his mind, distributing a photo of himself in athletic attire, giving a thumb-up 11 Jan: Attacks Romney as a "vulture" capitalist, provoking conservative outcry that he should not criticise the free-market system

Attacks Romney as a "vulture" capitalist, provoking conservative outcry that he should not criticise the free-market system 16 Jan: His remark in a TV debate that Turkey is ruled by "Islamic terrorists" is seen as yet another gaffe Profile: Rick Perry

"He was asking to have an open marriage and I refused," she said.

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.