Donald Trump and Hillary Clinton padded their delegate totals with convincing wins in the valuable Arizona primary Tuesday night – but their respective rivals, Ted Cruz and Bernie Sanders, kept the race alive with victories in the Utah and Idaho caucuses.

The Associated Press projected Sanders and Cruz the winners of the Utah contest early Wednesday morning. Idaho’s Democratic-only caucuses were called for Sanders.

Though Arizona was the biggest prize on the map in Tuesday's Western contests, Sanders and Cruz won their states by huge, double-digit margins. Cruz took all of Utah's delegates by finishing with more than 50 percent of the vote.

Together, the Western contests seemed to leave the race in a familiar place: with the front-runners building their tallies and trying to shift to a general election mindset, yet unable to shake underdog rivals buoyed by their own victories and finding reason to press on.

With Sanders' two wins, he roughly split Tuesday's delegate haul with Clinton. And Cruz’s victory in Utah indeed slows Trump’s march toward the nomination on the GOP side.

Yet both candidates continue to trail significantly, and Trump still will walk away from Tuesday’s Western state races with more delegates. That’s because Arizona, as the largest remaining winner-take-all contest on the map, will allocate all 58 of its delegates to the billionaire businessman.

See the Fox News 2016 battleground prediction map and make your own election projections. See Predictions Map →

In Utah, 40 were at stake.

On both sides, the contests were being held in the shadow of the deadly terror attack in Brussels, a tragedy that brought national security and foreign policy hurtling back to the forefront of the campaign trail debate.

Clinton, at an event in Seattle ahead of Saturday’s Democratic contest there, touted her Arizona win -- before pivoting to take shots at the Republican candidates for their response.

Citing hardline proposals from Trump and Cruz in the aftermath of the Brussels attack, she said: “The last thing we need, my friends, are leaders who incite more fear.”

Sanders, though, showed no signs of slowing down even as Clinton seemed to look past him. He rallied a crowd of cheering supporters in San Diego just minutes earlier, railing against his usual targets: a “rigged economy” and “corrupt campaign finance system.”

“We are doing something very unusual in modern American politics. We are telling the truth,” Sanders said.

At stake on the Democratic side Tuesday were 75 delegates in Arizona; 33 delegates in Utah; and 23 in Idaho.

Meanwhile, a frenzy of activity and turnout snarled polling places earlier Tuesday across the Western contests, leading to waits of over two hours at some locations in Arizona. In Utah, the state Democratic Party's website crashed due to high traffic. And Democratic leaders kept locations open longer than planned in Idaho.

The Western state contests, for Republicans in particular, marked one of the last chances to set the tone of the race before a lull in the primary calendar. Democrats have another round of contests this weekend, but Republicans will compete in only one state over the course of the next four weeks.

Amid efforts by his rivals to force an “open” convention in July, Trump has voiced confidence in recent days that he can clinch the GOP nomination by winning 1,237 delegates before then. Both Trump and Clinton have been eager to turn to a general election battle, each expecting to face the other in November.

But Trump likely will have to wait at least until late April, when the next round of major contests is held, to have a chance at driving his remaining rivals out of the race.

On the Democratic side, Sanders is clinging to hope that as the race turns from Clinton’s Southern stronghold to Western and other states, he can start to make up his gaping delegate deficit. His road to victory remains incredibly narrow.

The underdogs’ goal on the Republican side may be more attainable: Win just enough delegates to hold Trump under the requisite 1,237 delegates and trigger a contested convention in Cleveland.

As of early Wednesday morning, Trump had 739 delegates to Cruz’s 465. Ohio Gov. John Kasich trailed with 143.

From the start, Arizona's primary seemed custom-made for a Trump victory. The state has long dealt with illegal immigration problems, and the Republican front-runner's central campaign promise is to build a wall across the entire southern U.S. border. Trump also enjoyed the backing of former Arizona GOP Gov. Jan Brewer and Maricopa County Sheriff Joe Arpaio, two of the most outspoken voices on illegal immigration. 

Yet Cruz was poised to do well in Utah. Mormons are a large voting bloc there, and Trump lost to Cruz in Mormon-heavy Idaho earlier this month. Fellow Mormon and outspoken Trump critic Mitt Romney, the 2012 GOP presidential nominee, also pushed to get out the vote for Cruz in recent days. 

As voters went to the polls Tuesday, national security once again was front and center, in the aftermath of the Brussels terror bombings for which the Islamic State has taken responsibility.

Earlier, Trump called for an end to the U.S. Visa Waiver Program and told Fox News, “I’ve been talking about this for a long time.”

Cruz went more directly at President Obama and his immigration policies, including his plan to allow tens of thousands of Syrian refugees into the United States.  

“The time for the president’s political correctness has passed,” Cruz said. “We absolutely have to revisit our immigration policy across the board to prevent Islamic terrorists from coming in.”

On the Democratic side, Sanders desperately was looking for a win after getting swept in five March 15 contests. 

As of early Wednesday, Clinton had 1,681 delegates to Sanders’ 927. It takes 2,383 to clinch the Democratic nomination. 

Sanders invested a lot of time in the Western contests. He was the only 2016 presidential candidate to skip speaking Monday at the American Israel Public Affairs Committee conference in Washington to stay on the campaign trail. 

The Associated Press contributed to this report.