Billionaire Mr Trump is likely to get more than twice the number of votes of the next Republican candidate.
Senator Bernie Sanders, who beat Democratic rival Hillary Clinton by a huge margin, said his victory showed people wanted “real change”.
Both candidates are riding on a wave of discontent with mainstream politics.
Ohio Governor John Kasich came second in the Republican vote, with former Florida Governor Jeb Bush, Texas Senator Ted Cruz and Florida Senator Marco Rubio all vying for third place.
New Hampshire is the second state to choose delegates in the long nomination battle following last week’s Iowa caucuses, which were won by Mr Cruz for the Republicans and Mrs Clinton for the Democrats.
The result gives momentum to the winners ahead of the next contests in South Carolina and Nevada.
Mr Trump’s lead in New Hampshire is the first time the New York businessman – who has never held elected office – has translated his widespread support in opinion polls into a victory at the polls.
In his victory speech, the real estate mogul congratulated Democratic winner Mr Sanders but sideswiped that “he wants to give away our country, folks!”
Mr Trump, 69, has pledged to deport millions of migrants who are living in the US illegally; build a wall along the border with Mexico; and impose a temporary ban on all Muslims entering the country.
With close to 90% of the votes counted, Senator Sanders has a lead of more than 20 percentage points over Mrs Clinton in the two-horse race for the Democratic nomination. He had topped polls in New Hampshire in recent months, but it is still a significant victory for the self-described Democratic socialist candidate.
“What the people here have said is that given the enormous crises facing our country, it is just too late for the same old, same old establishment politics and establishment economics,” Mr Sanders said in speech to his supporters late on Tuesday.
The 74-year-old has vowed to eradicate income inequality, provide free university education and break up big banks.
Mrs Clinton congratulated Mr Sanders, but said in a speech she would continue to fight for every vote in the campaign. Despite the setback, she still remains the frontrunner for the nomination.
Who is John Kasich?
More from the Republican candidates:
Ohio Governor John Kasich, who performed strongly in New Hampshire, says he wants to lead America and “leave no-one behind”
Florida Senator Marco Rubio, who came a close third in Iowa, says he is “disappointed” with his New Hampshire finish and apologises to his supporters on Twitter
New Jersey Governor Chris Christie delivers a sombre speech, saying he would head home before deciding whether to proceed on to South Carolina or not
Jeb Bush, once considered the Republican frontrunner, tells a crowd of supporters “we’re going to South Carolina!”
Analysis: Anthony Zurcher, BBC North America reporter in New Hampshire
Donald Trump is back, and Bernie Sanders is booming. That’s the clear takeaway from a New Hampshire primary night that ended with little drama at the top. Both the New York billionaire and the Democrat who derides the billionaire class appear poised to confirm their consistently large opinion poll leads here with double-digit wins.
For the past few weeks the drama on the Republican side has been the identity of the candidate who will finish second – and perhaps become the establishment candidate to take on Mr Trump and Iowa caucuses winner Ted Cruz.
For a while it looked like that man would be Florida Senator Marco Rubio, but he seems destined for a middle-of-the-pack finish after a flop in Saturday’s debate. Instead it could be John Kasich. But the Ohio governor has little in the way of campaign infrastructure set up in the southern states that vote next in the primary process.
Tuesday’s results are likely to lend little clarity to the question of who gets the backing of mainstream Republicans. That’s good news for Mr Cruz and Mr Trump, who will benefit from a fractured establishment field for at least a while longer.
Winner and losers from New Hampshire
Mrs Clinton’s campaign manager, Robby Mook, said in a memo that they expected the race for the Democratic nomination “very likely” to be decided in March.
The former secretary of state acknowledged before the polls that Mr Sanders had a natural advantage in New Hampshire because he represents the neighbouring state of Vermont as senator.
Mrs Clinton, who has more support from the Democratic establishment, narrowly won in Iowa.
Most polls in New Hampshire closed at 19:00 local time (midnight GMT), with state officials forecasting a historic turnout in the vote.
What are primaries and caucuses?
They are the first contests in the US presidential race in which states decide who becomes each party’s official candidate
Caucuses are a series of private meetings in which voters express support for candidates with a show of hands. Usually only registered voters, affiliated with a specific party, can take part
Primaries are run by state governments and voting is done in a secret ballot
Each primary or caucus earns delegates for the winning candidates who then vote for them at party conventions in July in which the final candidates are formally confirmed
Key dates to come
20 February – South Carolina primary (Republican); Nevada caucus (Democrat)
23 February – Nevada caucus (R)
27 February – South Carolina primary (D)
1 March – ‘Super Tuesday’ – 15 states or territories decide
18-21 July – Republican convention, nominee picked
25-28 July – Democratic convention, nominee picked
8 November – US presidential elections]]>