On the night Michigan and Mississippi Democratic voters went to the polls, candidate Hillary Clinton said she was proud of the campaigns she and Sen. Bernie Sanders (I-Vt.) are running. Meanwhile, Sanders expressed confidence that Democrats would "beat Mr. Trump" in November. (Sarah Parnass/The Washington Post)

Sen. Ted Cruz has been projected to win the Republican presidential primary in Idaho, according to exit polls and early returns — a key victory for Cruz, after billionaire front-runner Donald Trump won the night’s first two GOP contests.

The Associated Press projected Cruz as the winner at 12:14 a.m., when Cruz was leading Trump by 15 points with 49 percent of precincts reporting. This is the seventh state Cruz has won. Trump has now won 14, including Michigan and Mississippi earlier on Tuesday evening. There is still one state up for grabs on Tuesday: Hawaii, where returns from the GOP caucuses are not expected until early morning, Eastern time.

The night’s biggest surprise, however, came in the Democratic presidential race, where Vermont Sen. Bernie Sanders won an upset victory over former Secretary of State Hillary Clinton in Michigan.

Pre-election polling had shown Clinton with a significant lead in Michigan. But Sanders took the lead as early returns came in, and he never gave it back: the Associated Press projected Sanders as the winner at 11:33 p.m., when he was leading by 50 percent to 48 percent, with 91 percent of the precincts reporting.

Tracking the race to the Republican nomination

For Sanders – the “democratic socialist” from Vermont running an insurgent campaign on Clinton’s left – the Michigan victory will bring a new energy, after several weeks in which his chances had seemed to fade.

Michigan is the largest state he has won, and the most diverse. It signalled that Sanders’ long efforts to attract black voters, by talking about racial justice and police brutality, had finally paid off. He only lost African American voters by a margin of 2 to 1, instead of the lopsided losses seen elsewhere. That, paired with Sanders’ stronger support among blue-collar whites, put him over the top.

Sanders was outperforming Clinton even in Genesee County, Mich. – whose county seat is Flint. Both Clinton and Sanders had focused heavily on the water crisis in Flint, where mismanagement by a Republican-led state government had led to toxic lead leaching into drinking water.

As the results remained unexpectedly close, aides to Sanders scrambled around 10 p.m. to set up a podium and banner in an outdoor courtyard at the South Miami boutique hotel where Sanders, his aides and the traveling press were staying. The campaign had not previously announced plans for Sanders to address the media.

“What we have done is create the kind of momentum that we need to win,” Sanders said. “This has been a fantastic night in Michigan,” he said, noting that regardless of the final outcome he will claim roughly half the state’s delegates.

Earlier in the evening, Clinton had won the Democratic primary in Mississippi, thanks to a dominating performance among black Democrats there. Pre-election polling had showed her with a huge lead in Michigan. She still holds a commanding lead in the count of Democratic delegates – thanks, in part, to her lead among the “super-delegates” who aren’t beholden to primary voters, but get to make up their own minds instead. The victory in Michigan will not change that. But it does signal that Clinton may not be able to “pivot” away from her primary fight – and toward a general election against a Republican – anytime soon.

Among Republicans, the Michigan and Mississippi primaries were both won in commanding fashion by billionaire Donald Trump — two victories in far-flung states, which showed that furious attacks by Trump’s rivals and his own party elite had failed to blunt his momentum.

Polls have also closed in Idaho, the third of four states to hold a Republican contest on Tuesday. As the first returns came in after 11 p.m. Eastern time, Sen. Ted Cruz (Tex.) was leading, with Trump running second and Sen. Marco Rubio (Fla.) third. There is no Democratic contest in Idaho on Tuesday: Democrats will caucus there on March 22.

Hawaii Republicans also headed to the polls Tuesday.

In the first two Republican races of Tuesday night, early returns showed Trump winning by double-digit margins. There was little sign of a drop-off, even after days of attacks by Rubio, Cruz and super PACs, which had blasted Trump’s business record and called him un-trustworthy.

In a speech and press conference held at one of his golf resorts in Florida, Trump savored the win.

“They didn’t do so well tonight, folks,” Trump said. ‘There’s only one person did well tonight, Donald Trump. I will tell you. It’s true.”

But, even in triumph, he had clear that his rivals had gotten under his skin. Trump interrupted his talk of politics to offer a detailed defense of his name-branded products: he mentioned Trump Water, Trump Magazine, Trump University, Trump Vodka, Trump Wine and others.

“We have Trump steaks. And by the way, if you want to take one, we’ll charge you about 50 bucks a steak,” Trump said. It was, undoubtedly, the first time a presidential front-runner had interrupted a political event to sell steaks and alcohol with his name on them. But Trump has won by breaking taboos: in the most recent debate, he was undoubtedly the first presidential front-runner to talk about the size of his genitals on stage.

On Tuesday — at least in the early going — Trump was the dominant force in the GOP race.

In Michigan, the second-place candidate was Ohio Gov. John Kasich. In Mississippi, it was Cruz. But neither was close to catching Trump.

For Rubio, the night was shaping up as a disaster. Rubio was running fourth in both stages, far below the threshold needed to win any delegates at all.

Rubio spoke to his supporters early in the evening, and said he would re-focus his energies on winning his home state of Florida, whose crucial “winner-take-all” primary is next Tuesday.

“I believe with all my heart that the winner of the Florida primary next Tuesday will be the nominee of the Republican Party,” Rubio told a crowd in Ponte Vedra, Fla., reiterating that he hopes to win his home state’s 99 delegates next week by defeating Trump. Rubio’s candidacy seems to be flagging. A loss on home turf would likely end it.

The victories in Michigan and Mississippi may not significantly increase Trump’s lead in the count of Republican delegates, since the two states give them out proportionately. The second-place candidate, and even perhaps the third- or fourth-place candidate, will also get a share. But, for Trump, these victories will still be undoubtedly sweet, since they came after the first sustained attacks against him.

In the Democratic race, the contest in Michigan was looking far closer than pre-election polls suggested. One reason, preliminary exit polling reported by CNN, was that Sanders did far better with African American voters in Michigan than he has in the Deep South.

In Michigan, Sanders was losing African American voters by a 2-to-1 margin to Clinton — and that was great news for the senator.

Sanders has lost black voters to Clinton — by an average margin of 84 percent to 16 percent according to exit polls so far this year — including a series of southern states where African Americans make up a large share of the electorate. Such massive losses were also partly responsible for him losing the close Nevada caucuses. But Sanders garnering over 30 percent of African American support in Michigan would mark a new high for the year.

Earlier in the night, the Associated Press projected Clinton as the winner in Mississippi – where her strong support among black voters was decisive – just after the polls closed at 8 p.m. Eastern time. AP projected Trump as the winner of the state’s GOP primary about 40 minutes later, as early returns showed him with a double-digit lead over Sen. Ted Cruz (Tex.), his nearest rival.

For both Clinton and Trump, Mississippi was the latest in a series of victories across the Deep South, which have helped both cement their status as front-runners. The two of them have played to widely different electorates in those states, with Clinton speaking to black voters pleased with the performance of President Obama, and Trump speaking to white Republicans who have turned even more conservative and embittered – with Obama and with their own party leadership — in the same period.

African Americans accounted for roughly 6 in 10 voters in Mississippi’s Democratic primary, which would mark a record high if it holds according to preliminary exit polling reported by ABC News. Black voters went strongly against Clinton in 2008, when she was defeated in the Democratic primary by then-Sen. Barack Obama. But, in this election, they have helped Clinton swamp Sanders in a series of southern states. In Mississippi, Clinton was hoping that black voters could give her a lopsided victory, as well as the bulk of the state’s 36 Democratic delegates.

Clinton won nearly 9 out of 10 black voters in Mississippi, according to exit polls reported by ABC News. Clinton also won white Democrats in Mississippi, however, by nearly a 2 to 1 margin.

Sanders has won eight states, but – because his victories were in smaller states, and because Clinton, with 12 state wins, has dominated among “super delegates” that make up their own minds – Sanders is still far behind in the race for delegates to the Democratic convention.

In early returns from the GOP race in Mississippi, Trump held a double-digit lead over Cruz. In exit polls, 85 percent of Mississippi Republican primary voters said they were evangelical Christians in preliminary exit polling reported by CNN, similar to 83 percent in 2012. Cruz had hoped these voters would be strongly for him, campaigning heavily in the South. But — in Mississippi as elsewhere — Trump appears to have blocked Cruz from gaining an edge in this group.

Early exit polling data found Trump with a small edge among evangelical Christians. Trump also had 2 to 1 lead over Cruz among those who did not call themselves evangelicals. In Mississippi, that group accounted for just 15 percent of the electorate.

Trump has dominated in the deep South, where he has won a solid block of states that stretches from Louisiana and Arkansas in the West to South Carolina in the East. His rivals have won eight states between them.

Robert Costa, Juliet Eilperin, Ed O’Keefe, Abby Phillip, Phillip Rucker, John Wagner, David Weigel and Niraj Chokshi contributed to this report.