With Trump's victory, attention shifted to the runners-up in the race.
Several candidates needed a strong finish to ensure the survival of their campaigns.
Marco Rubio, a 44-year-old Florida senator, hoped to build on a solid third-place finish in Iowa and brush off a rocky performance in last weekend's Republican debate.
Former Florida Gov. Jeb Bush, Ohio Gov. John Kasich and New Jersey Gov. Chris Christie have spent most of their time in the state in recent weeks and needed to show voters, as well as crucial financial donors, that they're viable candidates.
If Rubio and the governors finish in a pack, it's likely to frustrate Republican Party elites who are eager to coalesce around a single more mainstream candidate to challenge Trump and Cruz, whom they believe could be unelectable in the November general election.
At stake Tuesday were less than 1 percent of the delegates who, at party national conventions in July, will choose nominees to succeed Obama.
But a strong showing in New Hampshire can result in a wave of media coverage, donations and give a candidate momentum ahead of races 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.
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.
Clinton has cast herself as more pragmatic and able to achieve her agenda by working with Republicans, who are likely to continue to control at least one chamber of Congress after the election.
She has been on the defensive, though, about her ties to Wall Street 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.
The northeastern state was friendly territory for Sanders, a senator from neighboring Vermont, and was a must-win for him to stay competitive with Clinton as the race moves to more diverse states that are seen as more hospitable to Clinton.
The enthusiasm behind Sanders and Trump underscores the public's anger with the U.S. political system. Even if neither candidate ultimately becomes his party's nominee, whoever does will have to reckon with the voter frustration they've tapped into.For Trump, New Hampshire was his state to lose.
After his second-place finish in Iowa, he accepted some of the more traditional trappings of presidential campaigns, including smaller town hall meetings with voters. Still, he closed the final full day of campaigning with a vulgar insult of Cruz.
The Texas senator brushed off Trump's comments, saying the reason Trump engages in insults "is because he can't discuss the substance."
Cruz has also seized on anti-establishment sentiment with his uncompromising conservativism.
But he was a longshot to win in New Hampshire, where Republican voters are more moderate and less religious than in Iowa.
The Huffington Post has this reaction to the result.
Democrats
What are the most important issues?
• 33 per cent income inequality
• 32 per cent economy
• 25 per cent health care
• 8 per cent terrorism
Time of decision?
• 23 per cent last few days
7 per cent last week
15 per cent last month
55 per cent before that
Republicans
What are the most important issues?
• 30 per cent economy
• 27 per cent government spending
• 25 per cent terrorism
• 15 per cent immigration
Support banning Muslims from entering the US?
• 66 per cent support, 31 per cent oppose
Voting for the first time?
2016: 12 per cent; 2012: 12 per cent
Time of decision?
• 46 per cent last few days
• 6 per cent last week
• 16 per cent last month
• 32 per cent before that
Delegates at stake in New Hampshire
Democrats
• 24 delegates are up for grabs
• Hillary Clinton holds a big delegate lead, mainly due to on endorsements from superdelegates. Those are the party officials who can support the candidate of their choice.
• Clinton has 385 delegates and Bernie Sanders has 29.
• It takes 2382 delegates to win the Democratic nomination.
Republicans
• 23 delegates are up for grabs
• After the Iowa caucuses: eight for Ted Cruz, and seven each for Donald Trump and Marco Rubio.
• It takes 1237 delegates to win the Republican nomination.
Next contests
• Nevada caucuses on February 21.
• South Carolina primary February 28