Republican presidential candidate Donald Trump addresses ecstatic supporters following his win in the New Hampshire primary. (Reuters)

Donald Trump resoundingly won the New Hampshire Republican presidential primary Tuesday night, giving the billionaire mogul his first victory in an improbable and brash campaign that already has turned American politics upside down.

Ohio Gov. John Kasich, on the strength of his optimistic focus on economic renewal and lifting people out of the shadows, finished a distant second, while former Florida governor Jeb Bush and Sens. Ted Cruz (Tex.) and Marco Rubio (Fla.) headed toward a photo finish for third place.

Trump galvanized voters here with a visceral fixation on immigration and economic populism, affirming that even after last week’s setback in the Iowa caucuses, his candidacy has genuine appeal with the GOP base as well as with the independent voters who were part of his winning coalition.

Beaming as he claimed victory before hundreds of cheering supporters, Trump vowed to “work like hell” as president to fix what he sees as the nation’s chronic problems.

“We are going to make our country so strong,” Trump said. “We are going to start winning again. . . . We don’t win with anything. We are going to start winning again, and we are going to win so much, you are going to be so happy.”

Democratic presidential candidate Bernie Sanders thanked supporters for high voter turnout after winning the New Hampshire primary on Feb. 9. (Reuters)

On the Democratic side, Sen. Bernie Sanders notched a decisive win over Hillary Clinton in a state she had won in 2008. The Vermont senator’s win sets the stage for long nominating battle against the former secretary of state who is struggling to right her once-formidable campaign.

Written off as a fringe candidate when he launched his bid last spring, Sanders has found a receptive audience for his populist, anti-establishment message. His insurgent message casting Clinton a member of the old guard appears to be resonating with many voters. Sanders’s appeal Tuesday was greatest among younger voters, according to exit polls reported by CNN and other networks. But he also won decisively among male voters and held his own among female votes against Clinton.

“For many voters, there was a question about whether Senator Sanders’s message and his campaign could go toe to toe with the Clinton organization, and I think in Iowa he proved that we could,” said Sanders’s campaign mananger Jeff Weaver. “A victory in New Hampshire further amplifies that reality to voters all across the country.”

The Democratic race now moves to Nevada, which holds caucuses on Feb. 20, and then South Carolina, which holds a primary on Feb. 27. After that, 11 states hold contests on March 1, known as Super Tuesday.

Once a huge favorite in New Hampshire, Clinton had tempered expectations of late, and her campaign had sent out an email fundraising appeal that presaged her poor showing and looked ahead. “We absolutely, critically need to make sure Hillary comes out on top in the states that lie ahead,” the email said. “Our opponent is raising massive amounts of money online, and we need everyone on Team Hillary to step up, too.”

New Hampshire, the initial primary of the election year, could jolt the chaotic 2016 Republican race by re­invigorating the flagging candidacies of Kasich and Bush and delaying the winnowing of the establishment contenders.

“There’s magic in the air with this campaign,” Kasich told supporters in Concord. “We see this as an opportunity for all of us — and I mean all of us — to be involved in something that’s bigger than our own lives, to change America, to reshine America, to restore the spirit of America and the leave nobody behind.”

Rubio, who arrived in New Hampshire last week on a roll after claiming momentum from his impressive third-place finish in Iowa, suffered at the polls after his halting performance in Saturday night’s debate and a week of intense attacks from his rivals.

“Our disappointment tonight is not on you — it’s on me. I did not do well on Saturday night. So listen to this: That will never happen again,” Rubio told supporters in an uncharacteristically subdued speech Tuesday night.

Cruz, the Iowa victor, whose hard-line politics were an ill fit for New Hampshire, was in the hunt with Bush for third place. But New Jersey Gov. Chris Christie, who had staked his political future on this state, trailed the leading candidates in sixth.

Like many of his opponents, Christie was scheduled to take his campaign to South Carolina on Wednesday. But running low on money, and with the upcoming map looking bleak, he announced he would head home to New Jersey and discuss with his family whether to continue his campaign.

Turnout in the Republican primary was predicted by state officials to set a record of about 280,000 voters.

For Trump, the victory here was sweet vindication, showing that his atypical campaign — which invested relatively little in advertising, field organizing or data programs — could prevail largely on the power of celebrity and saturation media coverage.

In his speech Tuesday night, Trump cast himself as the savior for a beleaguered country. From trade to illegal immigration to terrorism to drug abuse, Trump said he offers the cure.

“I am going to be the greatest jobs president that God ever created — remember that,” Trump boasted. “We’re going to knock the hell out of ISIS.”

He added: “We are going to make America great again, but we are going to do it the old-fashioned way. . . . The world is going to respect us again, believe me.”

The margin of Trump’s win was the largest in a New Hampshire Republican primary since 2000, when John McCain defeated George W. Bush by 49 percent to 30 percent.

But there was also potential for concern in Tuesday’s outcome. As in Iowa, Trump faced doubts in the New Hampshire campaign about his discipline as a candidate and about whether he can build his support beyond the levels he has shown in the polls.

Those vulnerabilities are likely to be tested further in the upcoming contests in the South, starting with South Carolina’s Republican primary on Feb. 20 and turning a week later to a group of “Super Tuesday” states.

As the race moves south, Kasich faces immediate hurdles to prove that he is more than a one-state wonder. In the South, Trump has found deep and enthusiastic support for his incendiary nationalistic platform. Cruz is well positioned to contend with Trump for the top spot in those states because of his broad support from movement conservatives and evangelical Christians.

Jeb Bush, whose once-promising candidacy had languished since last summer, pulled out every stop over the past week in hopes for a finish strong enough to start a revival. Bush pledged to fight on to South Carolina, vowing that “this campaign’s not dead.”

He said pundits last week had declared “a three-person race between two freshman senators and a reality-TV star. And while the reality-TV star’s still doing well, it looks like you all have reset the race.”

Cruz avoided raising expectations that he might win in New Hampshire and instead tried to showcase his organizational strength in states where he thinks voters will be looking for an ideologically consistent conservative.

Another candidate with his eye on the South is Ben Carson, a retired neurosurgeon, who sees a more hospitable environment for his soft-spoken and faith-infused conservatism. He finished fourth in Iowa but fell behind in New Hampshire amid campaign difficulties.

Twenty-three delegates were to be awarded proportionally in New Hampshire’s Republican primary, a fraction of the 1,237 total needed to secure the nomination. Yet in recent presidential campaigns, New Hampshire has played an important role in crowning the eventual nominee — Mitt Romney in 2012 and John McCain in 2008 — and the state prides itself on a better track record than Iowa of predicting winners.

But the state also has a history of being a launching pad for insurgent candidacies with a maverick streak, including Patrick J. Buchanan, who defeated Robert J. Dole in 1996, and McCain, who bested George W. Bush in 2000. Trump in many ways has echoed Buchanan’s nativist emphasis on immigration and trade.

Party leaders and prominent donors had hoped that New Hampshire would deliver a clarifying verdict that would anoint a consensus establishment candidate who could challenge Trump and Cruz.

But there was little finality to Tuesday’s result. The jumbled finish signaled that the nominating battle may be contentious and crowded for weeks to come as a half-dozen or so candidates see reasons to soldier on.

Kasich’s rise in New Hampshire was as quiet as Trump’s was loud. During a political season in which a number of voters seemed drawn to outsiders, Kasich ran squarely on his insider credentials: 18 years in the House, an architect of a balanced federal budget, a denizen of Wall Street and the Fox News Channel studios, and a two-term governor of Ohio.

The sometimes cantankerous 63-year-old governor shrugged off his skeptics, trained his eyes on New Hampshire and ground out an old-fashioned campaign. He held 106 town hall meetings in every corner of the state, charmed local Republican leaders and won a large share of newspaper endorsements.

In the closing days, as his opponents lobbed increasingly caustic attacks at one another, Kasich took a different route, refusing to engage in the negativity and sounding upbeat and even-tempered in Saturday night’s ABC News debate.

Celebrating his second-place finish, Kasich told supporters, “Tonight, the light overcame the darkness of negative campaigning.”

The debate was a harbinger for other candidates, too. Rubio’s jarring and mechanical repetition of his talking points — as Christie assailed him for being callow and rehearsed — zapped the energy that came with his Iowa finish. In the days since, he was widely mocked from local radio programs to national late-night television.

Although he tried, Rubio did not recover quickly enough to salvage his standing in New Hampshire. Still, he was set to carry on as a top-tier national candidate.

Despite having knocked Rubio down in the debate, Christie did not reap the rewards himself. He was burdened by his state’s fiscal record and administrative scandals as well as with stinging ads from a pro-Rubio super PAC highlighting some of the governor’s past liberal positions.

Bush also hoped to be buoyed by Rubio’s stall. Running as a conservative voice of reason and an aggressive Trump foe, he slowly found his footing here and was assisted by his allied super PAC’s substantial, multimillion-dollar advertising blitz.

Overall in New Hampshire, more than $72 million was spent by outside groups alone, including ad buys, media production and direct mailers, according to federal filings as of Feb. 9.

Carly Fiorina, a former technology executive who briefly ascended as a grass-roots favorite after fiery debate performances, finished with just 2 percent of the vote in Iowa. In New Hampshire, she clocked another finish in the low single digits, which could add pressure on her to drop out.

Anu Narayanswamy in Washington contributed to this report.