Donald Trump, the celebrity mogul whose brash and un­or­tho­dox presidential bid was counted out time and again, became the de facto Republican nominee Tuesday night after a runaway victory in Indiana’s primary forced his two GOP rivals, Ted Cruz and John Kasich, to quit the race.

Trump overcame a spirited last stand by Cruz — and a patchwork movement of Republicans working desperately to derail him in fear that his polarizing politics could doom the party — to gallop to the nomination. Indiana’s results positioned him to easily accumulate the 1,237 delegates required to avert a contested convention.

Republican National Chairman Reince Priebus declared Trump the “presumptive nominee” and urged all Republicans to unite behind him.

Cruz dropped out Tuesday night in the aftermath of the drubbing, saying he saw no path forward to the nomination. Kasich, who won only his home state of Ohio, is set to announce his departure from the race later Wednesday in Columbus.

Sen. Ted Cruz (R-Tex.) suspended his presidential campaign May 3 after suffering a stinging loss in the Indiana primary to Republican presidential front-runner Donald Trump. (Reuters)

On the Democratic side, Indiana proved a surprising aberration as Bernie Sanders scored an upset victory over Hillary Clinton, giving the Vermont senator a needed psychological boost and a fresh rationale to soldier on against increasingly difficult odds.

But Sanders’s success did not change the overall trajectory of the Democratic race, which remains strongly in the former secretary of state’s favor. Clinton holds what her campaign and many analysts argue is an irreversible lead in total delegates. Although she has not clinched the nomination, she has shifted her focus to a likely general election campaign against Trump.

In Indiana, a large manufacturing state battered by shifts in the global economy, Trump and Sanders triumphed on the power of their populist pitches against free trade as well as by channeling the passions of voters who are distrustful of the nation’s political and economic systems.

As Trump claimed the mantle of GOP standard-bearer on Tuesday night, he was uncharacteristically measured. He remarked on his unlikely journey — “It’s been some unbelievable day and evening and year . . . a beautiful thing to behold” — and promised Republicans that he would not let them down. “We’re going to win big league, believe me,” he said at Trump Tower in New York. “We’re going after Hillary Clinton. She will not be a great president. She will not be a good president. She will be a poor president.”

Clinton, who campaigned Tuesday in the general election battleground of Ohio, now has her focus squarely on Trump. In a statement acknowledging Trump’s status as presumptive nominee, Clinton campaign chairman John Podesta said, “Throughout this campaign, Donald Trump has demonstrated that he’s too divisive and lacks the temperament to lead our nation and the free world. With so much at stake, Donald Trump is simply too big of a risk.”

The Hoosier State’s results capped an especially explosive day in the Republican race. In a last gasp on Tuesday morning, Cruz unloaded a litany of personal charges against Trump — a striking shift in tone that conveyed both the Texas senator’s frustrations with his fading fortunes and his freedom to finally speak his mind about the rival he once praised lavishly.

Republican presidential candidate Donald Trump held a campaign event at Trump Tower in Manhattan, after sweeping the Indiana primary. (Victoria Walker/The Washington Post)

But as Trump savored what his family members described as a shocking evening, he strived to be magnanimous in his remarks and singled out Cruz for praise. “Ted Cruz — I don’t know if he likes me or he doesn’t like me, but he is one hell of a competitor,” Trump said. “He is a tough, smart guy. And he has got an amazing future.”

Moments earlier, Cruz gave an emotional concession speech in Indianapolis. Flanked by his family and running mate Carly Fiorina, he said: “We left it all on the field in Indiana. We gave it everything we’ve got. But the voters chose another path. And so with a heavy heart but with boundless optimism for the long-term future of our nation, we are suspending our campaign.”

In a GOP race that began with 17 candidates — including four sitting governors, four sitting senators and an astoundingly well-funded scion of the Bush political dynasty — it was Trump who won over the party’s most restive and confrontational voters. He looks to California, which awards 172 delegates on June 7, the final day of primary voting, to make his nomination officially secure.

Trump faces an immediate challenge to unify the fractured GOP. There are already clear fissures, with Republicans Mark Salter, a former top adviser to Sen. John McCain (R-Ariz.), and Ben Howe, an editor of RedState, tweeting “I’m with her” — meaning they support Clinton.

Kasich held no public appearance on Tuesday night and scrapped plans to hold a news conference Wednesday morning at Washington Dulles International Airport. He will read a statement announcing the end of his campaign at 5 p.m. Wednesday, according to senior advisers.

Kasich entered the race with an impressive résumé: 18 years in the House, where he built a reputation as a budget cutter; a stint as a Fox News Channel host; and five years as the popular governor of a presidential swing state. He ran as a pragmatic conservative, one had defied his own party and expanded Medicaid, the federal health-care program for the poor, in Ohio. The message never caught on, and Kasich struggled to attract both fundraising and attention.

For Cruz, the last days of the race in Indiana were a painful demonstration that his time had run out. After Trump’s landslide April victories in six consecutive Northeast and Mid-Atlantic primaries, Cruz saw Indiana as an essential lifeline. His political operation went into overdrive, and he barnstormed Indiana as hard as any state since the kickoff Iowa caucuses. His allied super PACs spent millions of dollars advertising in the state.

Cruz’s moves over the past week signaled desperation. He struck a nonaggression pact with Kasich, who effectively pulled out of Indiana to give Cruz a one-on-one shot against Trump in exchange for Cruz ceding coming primaries in Oregon and New Mexico.

Cruz also named Fiorina as a running mate, and the two of them hurled fiery insults at Trump on the stump. Cruz escalated his rhetoric at a news conference Tuesday, labeling Trump “utterly amoral,” a “serial philanderer” and a “braggadocious, arrogant buffoon,” among other slurs.

None of it worked. Pre-primary polls showed Trump the chief beneficiary of the Cruz-Kasich deal and pulling farther ahead.

Trump left nothing to chance. Unlike in some earlier contests, his campaign aired television ads and ran a sizable field operation while the candidate kept up a busy schedule of massive rallies. Trump toured the state with retired Indiana University basketball coach Bobby Knight.

Cruz, meanwhile, was beset by bad luck. The Fiorina announcement was overtaken by news that former House speaker John A. Boehner (R-Ohio) had disparaged Cruz as “Lucifer in the flesh.” Cruz won a hard-sought endorsement from Indiana Gov. Mike Pence, but it drew notice instead for being markedly mealy-mouthed. Pro-Trump hecklers personally confronted Cruz outside one of his events. And Fiorina fell off a campaign stage.

Cruz’s frustrations boiled over Tuesday. After Trump attacked Cruz by referring to an unsubstantiated National Enquirer story alleging that Cruz’s father, Rafael, was connected to President John F. Kennedy’s assassin, Cruz unleashed his tirade.

Buoying Trump, 6 in 10 Indiana Republican voters — a larger share than in most previous contests — said they wanted the next president to come from outside the political establishment, according to preliminary exit polling reported by ABC News.

Similarly, nearly half of Indiana’s Republican voters were supportive of deporting undocumented immigrants, while that figure in earlier contests averaged 41 percent, the data showed. And more Republicans said that Cruz had run the most unfair campaign than said so of Trump, according to the exit polling.

Trump neutralized Cruz’s support from demographic groups — evangelicals, college graduates and voters who describe themselves as very conservative — that in previous primaries backed the Texan heavily, exit polling showed.

On the Democratic side, Clinton’s earlier victories were so commanding that she could withstand even a string of lopsided losses in May and still secure the nomination. Sanders has pledged to remain in the race until the end, even though his fundraising has slowed considerably and the scale of his political operation has been downsized accordingly.

But Sanders told reporters Tuesday night that he felt “a great deal of momentum.”

“I sense some great victories coming,” Sanders said. “And I think while the path is narrow, and I do not deny that for a moment, I think we can pull off one of the great political upsets in the history of the United States.”

David A. Fahrenthold and Scott Clement in Washington; David Weigel in Louisville; and Jenna Johnson in New York contributed to this report.