Progressive Senator Bernie Sanders led New Hampshire's Democratic presidential primary on Tuesday, and former front-runner Joe Biden trailed badly in a bruising setback that raises doubts about the viability of his campaign.

In the second nominating contest to find a challenger to Republican President Donald Trump in November, Sanders had 27 percent, while Pete Buttigieg, the moderate former mayor of South Bend, Indiana, was at 24 percent with 65 percent of precincts reporting.

Senator Amy Klobuchar, looking for a breakthrough after a strong debate performance on Friday, was in third with 20 percent.

Biden, the former vice president, was a distant fifth in the early results with 8.5 percent, behind Senator Elizabeth Warren with 9.4 percent. Biden, sensing the disappointing result, left New Hampshire for South Carolina before the results started rolling in.

The results began to thin the field of Democrats seeking the right to take on Trump in the Nov. 3 election, with businessman Andrew Yang and Senator Michael Bennet dropping out after the polls closed and it became clear they would finish well out of the running.

The moderate Biden was limping to his second consecutive disappointing finish after a fourth-place result in Iowa. He is certain to face growing questions about his ability to consolidate moderate support against a surging Buttigieg and Klobuchar.

Biden, 77, fared poorly in two previous runs for president before winning election in 2008 as President Barack Obama's No. 2. He hopes to stay afloat this time until Feb. 29 contest in South Carolina and a series of contests in other Southern states on Super Tuesday on March 3, where his support among African-Americans will be a strength.

"It ain't over, man. It's just getting started," Biden told supporters in South Carolina.

Bernie Sanders
Bernie Sanders Wikimedia Commons

Democrats' hope in New Hampshire

Results rolled in relatively quickly, and Democrats in New Hampshire were confident they would have smoother sailing than in Iowa, where embarrassing technical problems delayed vote-counting and the results for days. Buttigieg narrowly beat Sanders in Iowa, but both campaigns have asked for a partial recanvass of results.

On the Republican side, Trump was projected to win the state's presidential primary, easily defeating rival William Weld, the former governor of neighbouring Massachusetts, according to early exit polling compiled by Edison Research.

Democratic voters in New Hampshire chose a candidate from a ballot with 33 names, including candidates who dropped out weeks ago. But it did not include former New York Mayor Michael Bloomberg, a billionaire who is not competing in any states before the 14 Super Tuesday primaries on March 3.

Sanders had taken a lead in recent opinion polls in New Hampshire despite a barrage of criticism from rivals who warned his far-left views would lead the party to defeat against Trump. His win will enhance those worries among the party establishment.

Sanders, 78, who represents neighbouring Vermont in the Senate, won New Hampshire easily over rival Hillary Clinton with 60 percent of the vote in his unsuccessful bid for the party's nomination four years ago.

MORE DIVERSE BATTLEGROUNDS AHEAD

After Iowa and New Hampshire, small and rural states with predominantly white populations, the race will move on to more diverse battlegrounds that pose new tests.

Up next will be Feb. 22 caucuses in Nevada, which has a large Latino population, and the Feb. 29 primary in South Carolina, which has a large African-American population.

"Because of you, we are taking this campaign to Nevada," Klobuchar told supporters in New Hampshire.

Warren said it would be a long, drawn-out battle for the nomination and the race was far from over. She decried the party's infighting and called for unity as the contest moves on.

"These tactics might work if you're willing to burn down the party to be the last man standing," Warren said in New Hampshire. "We win when we come together."

Democrats in New Hampshire and in the other states that will vote in the state-by-state battle for the Democratic nomination are trying to decide whether they want to pick a moderate like Buttigieg, Klobuchar, Bloomberg and Biden, or progressive leaders like Sanders and Warren, who represents neighbouring Massachusetts.

The departures of Yang and Bennet left nine Democratic candidates still running.

Yang, 45, who was bidding to be the country's first Asian-American president, had surprised many observers by qualifying for debates and remaining in the contest longer than some veteran politicians.

Bennet, 55, a moderate from Colorado who had stressed improving education for Americans, told supporters it was "fitting" to end his campaign in New Hampshire, where he had campaigned heavily.