Cruz's double-digit win over Trump was a breakthrough for Republican Party forces battling to block the controversial New York billionaire, and it raised the prospect of a prolonged nomination fight that could last to the July convention in Cleveland, Ohio.
Democratic presidential contender Bernie Sanders also won in Wisconsin, gaining momentum in his fight against front-runner Hillary Clinton and trimming her commanding lead in delegates.
Trump entered the night with 737 convention delegates to Cruz's 481, leaving him 500 delegates short of the 1,237 needed to become the party's nominee in the Nov. 8 election.
Cruz said the result in Wisconsin showed the party was beginning to rally behind him, but he acknowledged the growing possibility that the fight could go all the way to the convention.
"Either before Cleveland, or at the convention in Cleveland, together we will win a majority of the delegates and together we will beat Hillary Clinton in November," Cruz told cheering supporters in Milwaukee. "We're winning because we're uniting the Republican Party."
Cruz, a conservative U.S. senator from Texas, was aided in Wisconsin by Republican Governor Scott Walker, who dropped his own presidential bid in September, and by a barrage of ads from Super PACS - independent funding groups - backed by party establishment figures worried that Trump will lead Republicans to a broad defeat in November.
Trump's campaign released a blistering statement saying Cruz had been propped up "by countless millions of dollars of false advertising" from anti-Trump Super PACs.
"Ted Cruz is worse than a puppet - he is a Trojan horse, being used by the party bosses attempting to steal the nomination from Mr. Trump," the Trump campaign statement said.
The Wisconsin primary capped a difficult week for Trump, who was forced to backtrack after saying women who have abortions should face punishment if the procedure is outlawed, and who voiced support for his campaign manager after he was charged with misdemeanor assault for grabbing a reporter.
CRUZ GAINS ON TRUMP
A new Reuters/Ipsos poll on Tuesday showed Cruz about even with Trump nationally, with Cruz's recent gains the first time since November that a Trump rival has threatened his standing at the head of the Republican pack.
The poll of 568 Republicans, taken between April 1-5, showed Cruz winning the support of 35 percent of Republicans to Trump's 39 percent. Cruz and Trump were also briefly about even early last week.
In the Democratic race, the win for Sanders, a U.S. senator from Vermont, is his sixth in the last seven contests for the nomination. Sanders said his message of breaking up big banks, reining in Wall Street and reducing income inequality was bringing new and young voters into the process.
"What we have been seeing throughout this campaign is extraordinary voter turnout in state after state," Sanders said at a rally in Laramie, Wyoming.
Clinton, who did not appear in public on Tuesday night, tweeted her congratulations to Sanders.
"Congrats to @BernieSanders on winning Wisconsin," Clinton said on Twitter. "To all the voters and volunteers who poured your hearts into this campaign: Forward! -H."
Sanders still faces a difficult task overtaking Clinton as the race moves to New York on April 19 and to five other Eastern states on April 26.
Heading into Tuesday, Clinton led Sanders by 263 pledged delegates in the race for the 2,383 needed to be nominated at the party's July convention in Philadelphia. She also has a big lead in superdelegates, who are party leaders free to back any candidate.
Sanders needs to win up to two-thirds of the remaining delegates to catch Clinton, who will keep accumulating delegates even when she loses under a Democratic Party system that awards them proportionally in all states.
Sanders needs to rack up big winning margins over Clinton in the remaining states to close the gap. He has vowed to stay in the race until the convention, and his campaign says superdelegates could begin to shift their support to him if they see he has popular support.