INDIANAPOLIS — Less than a month ago, Senator Ted Cruz seemed to have done it.

He had won Wisconsin. Former rivals were holding their noses to support him. He was dominating delegate elections, positioning himself for what seemed increasingly likely to be a floor fight at the Republican convention in July, as the campaign of Donald J. Trump fell into internal disarray.

“Tonight is a turning point,” Mr. Cruz said on primary night in Milwaukee. “It is a rallying cry.”

It was neither.

On Tuesday, Mr. Cruz ended his campaign, his loss in Indiana extinguishing any chance of denying Mr. Trump the nomination.

“Together we left it all on the field in Indiana,” Mr. Cruz told supporters here as cries of “Nooo!” rained from the crowd. “We gave it everything we’ve got. But the voters chose another path.”