A victorious Ted Cruz and buoyant Marco Rubio emerged from Iowa with compelling claims to the outsider and mainstream mantles in the fractured Republican primary, as the presidential race shifted overnight to New Hampshire. Democrats were girding for a protracted slugfest between Bernie Sanders and Hillary Clinton, locked in a virtual tie.

Cruz emerged with a comfortable lead Monday night to win the country's leadoff vote in what had been a close race until the end.

"We've built our campaign as a movement for Americans to organise, rallying and banding together against the disaster of the Washington cartel," Cruz told The Associated Press as he made his way to New Hampshire.

Donald Trump, uncharacteristically humble after a second-place Iowa finish, was headed for far friendlier territory in New Hampshire, where the billionaire firebrand has been running strong.

Amid historically large turnout in Iowa, the unexpected benefactor was Rubio, who came within striking distance of Trump. Republicans had already been looking to New Hampshire to winnow their congested field, and the Florida senator's strong showing bolsters his case that Republicans should coalesce behind him as the mainstream alternative to the rowdier Trump or Cruz.

Even with an elaborate campaign operation and backing from most Democratic Party leaders, Clinton was unable to stem a flood of enthusiasm from young and liberal voters for Sanders, the eccentric Vermont senator whose viability in a general election is still deeply questioned.

Although Clinton said she was "breathing a big sigh of relief", and her campaign said it had won an outright victory, the neck-and-neck contest was a blow, evoking the setback she faced in 2008 after her upset loss to then Senator Obama. Given the closeness of the Democratic caucuses, the AP did not declare a winner.

Eight years ago, Clinton's victory in New Hampshire breathed fresh life into her campaign. But New Hampshire is also familiar territory for Sanders, who represents neighbouring Vermont in the Senate and is well known among the state's voters. Sanders' sizeable lead over Clinton in New Hampshire polls has held steady or increased in recent weeks.