Republican presidential candidate Mitt Romney's hopes of a decisive victory in the Iowa caucuses were shattered early on Wednesday, when Christian fundamentalist Rick Santorum ran him a close second to provide the tightest finish in the party's history.

Although Romney won the first of the contests to choose a Republican nominee to take on Barack Obama, the night belonged to Santorum, who fought him to what was effectively a draw.

Only eight votes out of the 120,000 cast separated the two, with Romney picking up 30,015 votes and Santorum 30,007.

The failure of Romney to secure a clear-cut win throws the Republican race into disarray and opens the way for a protracted and messy race that could drag on for months, fought state by state, beginning with the New Hampshire primary on 10 January.

The result was so close that both Romney and Santorum claimed victory. And Ron Paul, who was came in third, also claimed the win. The Republican party said there will be no recount.

Speaking as the final votes were being counted and the outcome still unknown, Romney tried to put the best face on it, congratulating Santorum but adding: "We think it has been a great victory for us here too." He added: "On to New Hampshire. Lets get the job done."

Santorum, the most socially conservative of the candidates and an advocate of a belligerent approach to Iran, declared: "Game on."

Texas governor Rick Perry, who was the frontrunner back in August, looks like being the main casualty of the night after coming in a dismal fifth. Speaking to his campaign staff, he scrapped his campaign plans and said he was returning to Texas for a rethink.

"With a little prayer and reflection, I will decide the best way forward," Perry said.

In spite of pushing Romney so close, Santorum could struggle in the upcoming contests in New Hampshire, South Carolina and Florida, where he has only a token organisation, having devoted himself almost exclusively to campaigning over the last year in Iowa.

But as an Iowa winner he can expect a big injection of funds, particularly from conservative rightwingers unhappy with the prospect of Romney as the Republican nominee.

The Democrats were one of the main beneficiaries of the night, looking forward to the Republicans spending months ahead in bloodletting, using up energy and funds on each other rather than Obama. The White House election is to be held on 6 November.

David Axelrod, heading up Obama's re-election team in Iowa, anticipated Santorum will now come under a sustained, negative advertising campaign.

"The sound Santorum is hearing right now is not the buzz of victory. It's the whirring of Romney super political action committee, preparing to carpet bomb him," Alexrod tweeted.

Santorum was helped to victory by Christian evangelicals, who make up about half the caucus-goers.

Romney left to fly to New Hampshire overnight to begin campaigning, with his first event scheduled for midday.

New Hampshire is Romney's stronghold, where he enjoys poll leads of 20%.

Iowa was a major setback for Romney, given he only managed to win a quarter of the vote, raising questions about his ability to enthuse the Republican base and the wider public in a general election.

He will receive a boost of sorts on Wednesday when the Republican nominee in 2008, John McCain, whose launchpad was New Hampshire, endorses him. But it is a mixed blessing, as many of the conservatives who distrust Romney also regarded McCain as being too moderate and his backing will reinforce their suspicion of Romney.

Paul's campaign team claimed it was now down to a two-man race between himself and Romney because Santorum did not have the resources to mount campaigns in other states.

Paul's national campaign chairman, Jesse Benton, said: "The Ron Paul campaign is celebrating a great victory tonight … This is now a two way race between establishment candidate Mitt Romney and the candidate for real change, Ron Paul."

Gingrich, who was frontrunner in the polls just a few weeks ago, took fourth place, surviving for the next round in New Hampshire in spite of being on the receiving end of $4m in negative ads from Romney.

The flops were Perry, and Bachmann, who came sixth. Jon Huntsman came last, but he opted not to compete in Iowa, and is awaiting the candidates in New Hampshire.

The turnout was a record 122,255 for the Republicans in Iowa. But it was only up by a few thousand, not enough to worry the Democrats. A big increase would have suggested the Republican base was fired up for the coming general election.

Sign up for the Guardian Today

Our editors' picks for the day's top news and commentary delivered to your inbox each morning.