WASHINGTON -- U.S. Sen. Ted Cruz of Texas announced Tuesday that he was ending his presidential campaign after losing the Indiana primary.

A path to victory "has been foreclosed," Cruz told supporters in Indianapolis.

"We left it all on the field in Indiana," he said. "We gave it everything we got, but the voters chose another path."

Cruz had counted on Indiana to deny Donald Trump the 1,237 delegates he needed for a first-ballot victory at the Republican National Convention in Cleveland. He even formed an alliance with Ohio Gov. John Kasich in which each candidate would be the anti-Trump candidate in different primary states.

Instead, Trump walked away with most, if not all, of Indiana's 57 delegates, the biggest trove until the June 7 primaries, where New Jersey and California will go to the polls.

Cruz also tried to shake up the race by announcing that former Hewlett -Packard chief executive Carly Fiorina, an unsuccessful candidate for the GOP presidential nomination, would be his running mate if he was to be the Republican standard-bearer.

First elected to the U.S. Senate with Tea Party support, Cruz was the leader of efforts to force a repeal of President Barack Obama's landmark health care plan, which extended coverage to millions of uninsured Americans. When House Republicans at Cruz's urging refused to pass a spending bill unless it cut off support for the health care plan, the federal government temporarily shut down in 2013. Cruz then voted against legislation to reopen the government.

While his Senate colleagues shunned him at the beginning of the campaign, Cruz started picking up some endorsements as he emerged as the strongest challenger to Trump.

Jonathan D. Salant may be reached at jsalant@njadvancemedia.com. Follow him on Twitter @JDSalant. Find NJ.com Politics on Facebook.