Republican US presidential hopeful Ted Cruz has stormed to victory in the Wisconsin primary, denting front-runner Donald Trump's chances of capturing the party's nomination before its convention.
For the Democrats, Bernie Sanders defeated Hillary Clinton, but still faces a mathematically difficult path to the White House.
Donald Trump's defeat capped one of the worst periods of his campaign, a brutal stretch that highlighted his weaknesses with women and raised questions about his policy depth.
While the billionaire businessman still leads the Republican field, Mr Cruz and an array of anti-Trump forces hope Wisconsin signals the start of his decline.
Mr Cruz told cheering supporters at a victory rally: "Tonight is a turning point.
"It is a call from the hard-working people of Wisconsin to America. We have a choice. A real choice."
The ultra-conservative Texas senator, who has a complicated relationship with Republican leaders, also framed his victory as a moment of unity for a party that has been roiled by a contentious primary campaign.
However, Donald Trump was unbowed. His campaign team released this biting statement: "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."
Bernie Sanders's sweeping win in virtually every county in Wisconsin except Milwaukee gives him greater incentive to carry on the fight against Mrs Clinton. But he still trails her in the pledged delegate count and has so far been unable to persuade superdelegates - the party officials who can back any candidate - to drop their allegiance to the former US secretary of state.
At a raucous rally in Wyoming, Mr Sanders said his victory was a sign of mounting momentum for his campaign.
"With our victory tonight is Wisconsin, we have now won seven out of eight of the last caucuses and primaries," he declared.
Mr Sanders is favourite to win the Wyoming Democratic caucuses on Saturday.
The results in Wisconsin make it likely both parties' primaries will continue deep into the spring, heaping uncertainty on Trump and Clinton and preventing both from fully setting their sights on the general election in the autumn.
In a sign of Mrs Clinton's low expectations in the Midwestern state, she spent Tuesday night at a fundraiser with top donors in New York City, which will hold its critical primary on April 19.
Mrs Clinton congratulated her rival on Twitter and thanked her supporters in Wisconsin. She wrote: "To all the voters and volunteers who poured your hearts into this campaign: Forward!"
Because Democrats award delegates proportionally, Mr Sanders' victory in Wisconsin will not cut significantly into Mrs Clinton's lead in the pledged delegate count. With 86 delegates at stake in Wisconsin, Mr Sanders will pick up at least 45 and Mrs Clinton will gain at least 31. The state-by-state nominating contests are choosing delegates to the parties' national conventions that will select the presidential nominees.
Mr Sanders must still win 67% of the remaining delegates and uncommitted superdelegates in order to win the Democratic presidential nomination.
Mrs Clinton now has 1,274 delegates to Mr Sanders' 1,025, based on primary and caucus results alone. When including superdelegates, Mrs Clinton has a wider lead - 1,743 to 1,056. It takes 2,383 delegates to secure the nomination.
Exit polls in the state underscored the concerns about Donald Trump that are surging through some corners of the Republican Party. A majority of Republican voters said they are either concerned or scared of a potential Trump presidency.
More than a third said they were scared about what Mr Trump would do as president, while about two in 10 said they were concerned, according to surveys.
With his victory on Tuesday, Mr Cruz won at least 33 Wisconsin delegates, while Mr Trump carried at least three. Six delegates are still up for grabs, pending the outcome in two congressional districts.
With Wisconsin results included, Trump leads with 740 delegates to Cruz's 508, while John Kasich has 143. It takes 1,237 delegates to win the nomination.
Mr Trump still has a narrow path to claim the nomination by the end of the primaries on June 7. But by losing Wisconsin, the real estate mogul has little room for error in upcoming contests.
He would need to win 57% of those remaining to clinch the Republican nomination before the July convention. So far, Mr Trump has won 48% of the delegates awarded.