INDIANAPOLIS—Sen. Ted Cruz on Tuesday departed the Republican presidential contest after having exhausted an array of campaign moves, ending a campaign that started as the longest of long shots but turned into a surprisingly durable effort to tap into the powerful antiestablishment sentiment of the 2016 electorate.

After being crushed in the Indiana primary that he had said would decide the fate of the Republican presidential campaign, Mr. Cruz dropped out, essentially ceding the nomination to front-runner Donald Trump. The...