Sen. Bernie Sanders and billionaire Donald Trump have won the Democratic and Republican presidential primaries in New Hampshire, in victories so decisive that the drama of primary night shifted to the Republicans battling for second, third and fourth place.

Projected to finish in second was Ohio Gov. John Kasich, a relatively moderate candidate who might face a difficult time unifying the party behind him in the next few primary states. After Kasich, there was a close race for third between Sen. Ted Cruz (Tex.) — who won the Iowa caucuses last week — and former Florida governor Jeb Bush.

Behind all of them was Sen. Marco Rubio (Fla.), who had been seen as the strongest challenger to Trump until a disastrous debate performance on Saturday, in which New Jersey Gov. Chris Christie attacked Rubio and the senator responded by repeating the same talking point over and over.

But if Christie’s attack had hurt Rubio, it didn’t seem to have helped Christie himself: Christie was running behind Rubio, last among the four “establishment” candidates.

The results for his challengers seemed to be a good one for Trump, since it was likely that a large number of them would continue on to the next primaries, dividing the voters who want to see Trump defeated.

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

[New Hampshire primary election results]

In the Democratic race, Sanders was projected as the winner over former secretary of state Hillary Clinton, who had been seen as her party’s prohibitive favorite a year ago.

“Nine months ago, we began our campaign here in New Hampshire, we had no campaign organization. We had no money. And we were taking on the most powerful political organization in the United States of America,” Sanders said to his supporters. “And tonight, with what it appears to be a record-breaking voter turnout, because of a huge voter turnout – and I say YUGE! – we won,” Sanders said, poking fun at the New York City accent he shares with Trump. The crowd had yelled “YUUUGE!” along with him.

Sanders said that the enthusiasm his supporters showed in New Hampshire could be replicated in other primaries and in a general election, with a strongly left-wing message drawing out new voters who’d be left unenthused by a centrist.

“That is what will happen all over this country!” Sanders said.

Sanders is a self-identified “democratic socialist,” originally little known outside Washington and his home state of Vermont. But he built a massive movement with rousing attacks on the power of Wall Street, and a promise of a “political revolution” that would provide universal, government-run health insurance and free public-college tuition.

Sanders was also helped by Clinton’s struggles to explain why she’d used a private email server to handle government business while she was secretary of state, a scandal that has hung over her candidacy for months.

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

“Now we take this campaign to this entire country. We are going to fight for every vote in every state,” Clinton told supporters after conceding. She then returned to a constant theme of her campaign, which was that she — unlike Sanders — was ready for the long slog that politics demands. “People have every right to be angry. But they’re also hungry. They’re hungry for solutions.”

Clinton’s defeat in New Hampshire was so resounding – and so long anticipated – that Clinton’s campaign conceded immediately when the polls closed at 8 p.m. The campaign sent out a statement downplaying the importance of New Hampshire, which Clinton won in 2008. Her campaign promised to fight on through March, including the next-up contests in Nevada and South Carolina. The next states, Clinton’s campaign said, would be more likely to turn out her way.

[New Hampshire primary live updates:]

“Whereas the electorates in Iowa and New Hampshire are largely rural/suburban and predominantly white, the March states better reflect the true diversity of the Democratic Party and the nation,” Clinton’s campaign manager Robby Mook wrote in the statement. Clinton’s campaign has said it expects to do far better among African American and Latino voters than Sanders will.

Exit polls reported by CNN showed that Sanders had beaten Clinton across a wide variety of demographic groups — including women, who voted for Sanders by a margin of 55 percent to 44 percent.

Sanders also won decisively among self-identified independents, taking that group by 72 percent. The two candidates evenly split voters who identified themselves as Democrats. Sanders also won all the ideological groups that the polls surveyed: Democratic voters calling themselves “very liberal,” “somewhat liberal,” and “moderate” all preferred him to Clinton.

Another telling detail: Clinton won handily among the voters who said the quality they wanted most in a candidate was “electability.” Her advantage among that group was 81 percent to 18 percent. But Sanders dominated in the group that said the most important quality was that the candidate “cares,” and in the group that said it was most important that the candidate was honest. In the group that cared about honesty, Sanders won by 92 percent to 6 percent, according to CNN.

Among Republicans, Trump’s victory — even though it had been predicted for weeks — is still a remarkable turnabout. Last summer, Trump had seemed like an afterthought in a race that seemed likely to be dominated by former Florida governor Jeb Bush, and the massive campaign warchest assembled to back Bush.

But Trump’s TV experience made him a commanding figure in early debates, where other candidates seemed unsure how to handle a candidate who insulted their looks and told them to shush. And Trump’s blunt message, which promised a massive wall on the southern border and a program to deport 12 million undocumented immigrants, resonated with voters who felt their party had ignored the issue for too long.

“We are going to do something so good, and so fast, and so strong. And the world is going to respect us again. Believe me,” Trump said to supporters, during a speech that began with Trump thanking his late parents. Trump then reviewed a series of campaign promises, including his plan to build a wall on the southern border. “We’re going to build a wall. It’s going to be built. It’s not even, it’s not even a difficult thing to do.” He also said he would be “the greatest jobs president that God ever created.”

The crowd chanted “Trump! Trump! Trump!”

“That’s so beautiful,” Trump said.

In a moment that captured so much of this campaign, Trump’s speech happened at the same time as Bush’s own speech, and largely kept Bush – projected a year ago as the race’s favorite – off the air.

For Trump, the victory here in New Hampshire was a vindication of his unusual campaign style, which favored huge rallies and free TV exposure over the kind of data-driven, expensive voter-turnout efforts that mark most modern campaigns.

In Iowa, Trump used that approach and lost to Cruz and his high-tech “ground game.” But in New Hampshire, it was enough.

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

One of the big New Hampshire surprises was Kasich, a pragmatic Midwesterner whose candidacy has been an afterthought nationally but who steadily built a pitch-perfect campaign for this state that roused mainstream voters with high visibility on the ground and a call to lift up people in the shadows.

Kasich told supporters Tuesday night that his second place finish was evidence an optimistic message could win.

“There’s magic in the air with this campaign,” Kasich said. “We never went negative, because we have more good to sell.”

The Ohio governor called on supporters to join his effort “to re-shine America. To restore the spirit of America. And to leave no one behind.”

But the race now moves south, where Kasich faces immediate hurdles to prove he is more than a one-state wonder and where 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 coalition of movement conservatives and evangelicals.

Republican exit polls reported by CNN showed how dominant Trump’s victory in New Hampshire had been. Trump won among people who said they had been “betrayed by Republican politicians” – but also among those who didn’t feel betrayed.

Trump won both men and women, won the married and the unmarried, won college graduates and non-graduates, won high earners and low earners, and won both those who called themselves “conservative” and among those who called themselves “moderate/liberal.”

The few sub-groups that Trump did not win included those who called themselves evangelical or born-again: Cruz won that group with 24 percent. But his victory in that group – a core part of Cruz’s support – came by just a single percentage point. In second place, with 23 percent, was Trump. Kasich won among voters who said they were “somewhat worried” about the economy, though Trump won the group that said they were “very worried.” Trump lost among the voters who believed “electability” was the most important quality in a candidate: they went for Rubio.

One striking statistic in the poll came from a question that asked voters about what should be done with undocumented immigrants who were already in the U.S. Trump has said he would deport all 12 million of them. It was no surprise, then, that Trump won among the voters who supported mass deportation.

But he also won among voters who said that deportation was the wrong choice. Among that group of voters – the 66 percent of Republicans who supported offering legal status to undocumented immigrants, the exact opposite of Trump’s plan – 22 percent supported Trump anyway. That was enough to tie Kasich for first place.

The exit polls reported by CNN showed that 66 percent of Republican primary voters supported another idea that Trump has praised: a temporary ban on Muslim foreigners entering the U.S. In that group, not surprisingly, Trump was the most popular candidate, with 42 percent support.

For Republicans, the campaign trail in the final push was like a game of political billiards — with attacks flying fast and in all directions, reflecting the jumbled field and the uncertain fates that await so many of the candidates.

Bush fired at Trump, Cruz, Kasich and Rubio. Christie savaged Rubio. Rubio smacked back. Trump, for his part, slammed Bush and Cruz.

Tuesday night, Bush told his supporters, “The pundits had it all figured out last Monday night when the Iowa caucuses were complete. They said the race was now a three-person race between two freshmen 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.”

Recalling the story of a veteran he met who had been wrongfully declared dead by the Department of Veterans Affairs, Bush said, “Just like he’s not dead, this campaign’s not dead – we’re going on to South Carolina.”

For the Republicans, the character of the race appeared to change over the weekend after a Saturday debate in which Rubio faltered in the face of stinging barbs from Christie.

In an uncharacteristically blunt fashion, Rubio on Tuesday night blamed himself for his poor showing in the primary.

“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,” he vowed.

Late Tuesday, Christie seemed sobered by his defeat – and contemplating an end to his campaign. Before Tuesday’s results were in, Christie had said he planned to campaign in South Carolina, extending his campaign to the next primary state. Now, he said, he would return to New Jersey, and watch for the final results from New Hampshire.

“That’s going to allow us to make a decision about how we move from here in this race. But there’s no reason to sit in a hotel in South Carolina to hear that,” Christie said.

While in New Jersey, he said, “We can actually get a change of clothes, which would be a nice thing.”

If Christie does drop out because of New Hampshire, that would mark the end of a long decline for one of the most talented retail politicians in the race. Christie had once been the front-runner in New Hampshire, way back in 2014, but he was un-done by a scandal from his own administration – in which aides allegedly caused a traffic jam on a major bridge in order to punish a local mayor who hadn’t endorsed Christie’s re-election.

And he was out-shone by Trump, who stole away the role that Christie had sought to play: the race’s brash straight-talker.

Eilperin and Fahrenthold reported from Washington. Jose A. DelReal in Portsmouth, Jenna Johnson, Sean Sullivan and John Wagner in Concord, Michael Kranish in Plaistow, Abby Phillip, Anne Gearan, Ed O’Keefe and Karen Tumulty in Manchester contributed to this report.