MANCHESTER, N.H. -- Bernie Sanders won a commanding victory over Hillary Clinton in the New Hampshire primary Tuesday, and Donald Trump also scored a big win in a triumph of two candidates who have seized on Americans' anger at the Washington political establishment.

Both outcomes would have been nearly unthinkable not long ago. Sanders, a self-described democratic socialist, beat a former secretary of state and first lady once seen as the all-but-certain Democratic nominee. While Clinton remains the favourite in the national race for the Democratic nomination, the win by the Vermont senator could be a springboard into a competitive, drawn-out primary campaign.

For Trump, the brash real estate magnate and television personality who has never run for public office, the win was an important rebound after his loss to Texas Sen. Ted Cruz in last week's Iowa caucuses, the first nominating contest. Trump has led national polls for months and the New Hampshire victory reinforces his position as front-runner, proving he can win votes, and giving credibility to his upstart populist candidacy.

For some Republican leaders, back-to-back victories by Trump and Cruz, an uncompromising conservative, add urgency to the need to coalesce around a more mainstream candidate to challenge them through the primaries. However, Tuesday's vote did little to clarify who that candidate might be.

Ohio Gov. John Kasich finished second after devoting almost all of his campaign resources to New Hampshire, while Florida Sen. Marco Rubio and former Florida Gov. Jeb Bush battled for third, along with Cruz. New Jersey Gov. Chris Christie, who also staked his candidacy on New Hampshire, lagged behind the pack.

Rubio had appeared to be breaking away after a stronger-than-expected third-place showing in Iowa, but he stumbled in Saturday's Republican debate under intense pressure from Christie.

At stake Tuesday were less than 1 per cent of the delegates who, at party national conventions in July, will choose nominees to succeed President Barack Obama. But a strong showing in New Hampshire can give a candidate momentum ahead of state contests in coming weeks, including the March 1 "Super Tuesday, when 11 states vote.

Nearly half of voters in the Republican primary made up their mind in the past week, according to early exit polls conducted by Edison Research for the Associated Press and the television networks. Republican voters were more negative about their politicians than Democrats, with about half of Republican voters saying they felt betrayed by party officials.

In a sign of Trump's impact on the race, two-thirds of Republican voters said they support a ban on Muslims entering the U.S., a position the billionaire outlined last year amid rising fears of terrorism emanating from the Middle East.

Early exit polls showed Trump drew support from voters looking for an outsider and from those who made up their minds a while ago.

Among Democrats, Sanders, who narrowly lost in Iowa, had maintained a sizeable advantage over Clinton in New Hampshire for weeks. He has appealed to liberal Democrats who believe Obama hasn't done enough to address the nation's disparity in wealth.

Sanders said at a raucous victory party that his win would send a message across the nation "that the government of our great country belongs to all of the people and not just a handful of wealthy campaign contributors" and their political committees.

Clinton echoed Sanders' calls for taking on Wall Street banks and tackling income inequality, but cast herself as more prepared to make good on her policy pledges. "People have every right to be angry. But they're also hungry, they're hungry for solutions," she said after congratulating Sanders on his win.

But Clinton has been on the defensive, about her ties to Wall Street -- including hundreds of thousands of dollars in speaking fees from financial firms -- and her use of a personal email account for official business while secretary of state, which has raised questions about whether she mishandled government secrets and about her overall trustworthiness.

Clinton's campaign argues she will perform better as the race heads to more racially diverse states, including Nevada and South Carolina. Both New Hampshire and Iowa are overwhelmingly white states that are far less diverse than the nation -- and particularly the Democratic electorate -- as a whole.

"A Democrat who is unable to inspire strong levels of support in minority communities will have no credible path to winning the presidency in the general election," Clinton campaign manager Robby Mook said in a memo released as the polls closed.

While Sanders' victory means he's assured of a majority of the state's pledged delegates, Clinton remains ahead in the overall delegate count due to support from superdelegates -- the party officials who can support the candidate of their choice at the convention. Overall, Clinton has amassed at least 392 delegates and Sanders at least 42; the magic number to clinch the nomination is 2,382.

By winning New Hampshire, Trump will take the lead in the race for delegates for the Republican National Convention. But it won't be much of a lead.

There are only 23 delegates at stake in New Hampshire's Republican primary, and they are awarded proportionally, based on the statewide vote. Trump will win at least nine. A candidate needs 1,237 delegates to win the nomination.