Democratic presidential candidate Hillary Rodham Clinton scored a surprising upset in the New Hampshire primary Tuesday night, while Republican Senator John McCain staged his own comeback to pick up his first win in the race for the U.S. presidency.

The victory was a much-needed boost for Clinton, once considered the front-runner. Her campaign had appeared to be faltering after her surprising third-place finish to Illinois Senator Barack Obama in the Iowa caucuses last week.

hillary_cp_4140609

Supporters cheer as Democratic presidential hopeful Senator Hillary Rodham Clinton takes the stage after her primary win in New Hampshire. ((Jim Cole/Associated Press))

"Over the last week, I listened to you and in the process I found my own voice," she said to her crowd of supporters.

"Now together, let's give America the kind of comeback that New Hampshire has just given me."

Earlier, most of the polls showed Obama, vying to become the first black president and riding a wave of momentum from his Jan. 3 victory in the Iowa caucuses, with at least a double-digit lead over the New York senator. But Clinton, who wants to become the first woman in the Oval Office, received about 39 per cent support in unofficial results, compared with 37 per cent for Obama and 17 per cent for 2004 vice-presidential candidate John Edwards.

Comeback for McCain too

McCain's win was also considered a major comeback for the 71-year-old Arizona senator. He had been in a tough battle with former Massachusetts governor Mitt Romney, who suffered another defeat in New Hampshire after losing to Arkansas governor Mike Huckabee in Iowa last week. (Romney did win the most delegates at county conventions held across Wyoming on Saturday.)

Tuesday night results from New Hampshire showed McCain was attracting 37 per cent support, while Romney had 32 per cent.

Huckabee was running third with 11 percent; former New York Mayor Rudy Giuliani and Texas Representative Ron Paul were battling for fourth place with nine and eight per cent respectively; and actor Fred Thompson attracted only one per cent of the vote.

"I'm past the age when I can claim the noun 'kid', no matter what adjective precedes it. But tonight, we sure showed them what a comeback looks like," McCain told his cheering supporters.

mccain-speech-cp-4140291

Republican presidential hopeful Senator John McCain gives a thumbs-up as he arrives for his primary election victory party in Nashua, N.H. ((Charles Dharapak/Associated Press))

McCain had attracted criticism for his steadfast support of the Iraq war and the increase in troops posted to that country. He had also been criticized by members of his own party for a plan to give illegal immigrants an eventual path to citizenship. Illegal immigration has become a key issue among Republicans.

But as he changed his message on immigration to focus on border security first, and violence subsided in Iraq, McCain's support increased in recent months.

He is popular in the "Live Free or Die" state of New Hampshire for what are considered his maverick positions. 

This is the second time the Arizona senator has won the New Hampshire primary in his attempt to become president. In 2000, he defeated the eventual Republican victor, U.S. President George W. Bush.

Bill Clinton tried to dampen expectations

The New Hampshire poll numbers in Obama's favour had suggested his mantra of change was resonating more clearly among the state's voters than Clinton's change-through-experience message.

On Monday, in a last-minute pitch to voters, Clinton became emotional when asked how she gets out of bed in the morning for such a tough job.

Former U.S. president Bill Clinton, campaigning for his wife, had tried to dampen expectations for her in New Hampshire, saying there was an unusually short time for her to turn things around since Iowa voted last Thursday.

But he launched a stinging attack on Obama's Iraq voting record Tuesday, saying Obama's supposedly consistent stand against the war in Iraq is a "fairy tale."

He has also suggested that much of Hillary Clinton's trouble is the result of sexism.

According to exit polling conducted by the Associated Press and the television networks, far more women voted than men; Clinton won 45 per cent of them compared to 36 for Obama. Also according to exit polls, only half as many New Hampshire voters under 30 turned out as in Iowa, depriving Obama of crucial support.

Obama tells supporters he's still optimistic

But Obama remained optimistic about his second-place finish.

"You know, a few weeks ago no one imagined that we'd have accomplished what we did here tonight in New Hampshire," he told supporters. "For most of this campaign, we were far behind. We always knew our climb would be steep.

"But, in record numbers, you came out and you spoke up for change. And with your voices and your votes you made it clear that at this moment in this election there is something happening in America."

A series of states will hold primaries and caucuses for both parties during the next six months to determine the eventual Republican and Democratic presidential candidates, who will be officially nominated at the parties' national conventions in August and September before the November election.

While critical in terms of momentum and media coverage, the Iowa and New Hampshire contests make up only a fraction of available delegates who will pledge support for a candidate at the parties' national conventions.

With files from the Associated Press