Senator Bernie Sanders is celebrating on Wednesday after a major and unexpected victory in Michigan Tuesday night. Before the votes were counted, Hillary Clinton was widely expected to win the Wolverine State. Polls from earlier this week showed her with double-digit leads, some as high as 27 points, and yet she lost to Sanders on Tuesday, 50-48 percent.

How did everyone get it so wrong?

The Sanders campaign invested heavily in Michigan, counting on a victory or close race there to prove that he could win big and diverse states. He outspent the Clinton campaign in Michigan in the last week before the primary but the polls barely budged. Even Sanders didn't think he would win Michigan.

Prez ad spending in Michigan from Feb 29-March 6, based on Kantar Media tracking: — Mi Campaign Finance (@MichiganCFN)March 8, 2016

Still, one Michigan polling outfit wasn't completely off base. A Michigan State University poll released on Monday showed Clinton leading Sanders, but by just five points, within the survey's margin of error. The poll at the time looked like an outlier and was ignored by mainstream news outlets, in part because of its small sample size and the fact that MSU polled all adults -- not just registered voters -- over a six-week period.

MSU's Matt Grossmann said that he wasn't so much concerned about the lack of attention for his poll, but the heavy focus that political prognosticators and the national media placed on other polling in the state.

Generally speaking, much of Michigan's polling leaves out cell phone users and thus huge numbers of young voters, who disproportionately back Sanders, and some minorities. Many of those pollsters used voters' history of participating in the Democratic primaries to determine how likely they were to turn out. But Grossman pointed out in an interview with VICE News on Tuesday that Michigan hasn't had a competitive Democratic presidential race in a while. In 2012, President Obama ran unopposed and in 2008, he failed to get on the ballot there. "So it was really hard to figure out who was going to vote," Grossman said.

MSU has consistently shown Clinton and Sanders locked in a tight race in Michigan since the New Hampshire primary last month, Grossman said. But the MSU poll also predicted that Senator Marco Rubio would come in third place, not Ohio Governor John Kasich. That's because there has been a lot more volatility on the Republican side in recent weeks, Grossman said. While Trump has consistently led, the race for second place shifted over time. Over the full six weeks of MSU's most recent poll, Senator Marco Rubio performed strongly enough to nab a third-place finish. But Ohio Governor John Kasich surged in the week before voters actually cast their ballots and overtook him.

Sanders focused his message in Michigan on trade, repeatedly hitting Clinton over her support for trade deals that he said lead to job losses and factory closings in Michigan. The argument was apparently a powerful one in the state, where a majority of Democratic voters said that they believed international trade deals lead to job losses in the US, according to exit polls. Sanders won about 60 percent of those voters.

Sanders' campaign manager, Jeff Weaver, expects that argument to propel the campaign forward in other Rust Belt and Midwestern states as well. On a conference call with reporters after Super Tuesday, Weaver predicted that Sanders' message on trade "will be very powerful" not only in Michigan, but also in Ohio, Pennsylvania and other states where factories have shuttered in the last few decades as jobs have moved overseas.

Weaver also argued that the message could help Sanders to alleviate the problems he has had with black voters in some of the other states that have voted so far. Clinton has been winning the African-American vote by upwards of 60 points in Southern states (and did so again in Mississippi on Tuesday night). But in Michigan, Sanders did close the gap slightly, winning 30 percent of African-American voters, after idling in the teens among black voters in recent contests.

"It's pretty clear that the African-American community is not monolithic," Weaver last week. "And I think you know the experiences of communities in places like Michigan, you know, will perhaps make Bernie's message of economic empowerment a much more powerful and resonant message."

The bulk of Clinton's support from black voters so far has come in southern states. Whether Sanders can translate his gains in Michigan into increased support among African-American voters in other regions remains to be seen.

There is also anecdotal evidence that Michigan's open primary system may have helped Sanders. Voters in the state can vote in the primary for whichever party they like and some reporters on the ground noted that they'd met some Clinton supporters who were so sure of her victory there (see the polling issues above) that they opted to vote against Donald Trump in the Republican primary instead.

I just keep meeting Dems in MI who say Hillary has the primary locked, so they cast anti-Trump votes for Kasich. — daveweigel (@daveweigel)March 8, 2016

Grossman noted that Democratic turnout was actually higher than expected on Tuesday, so the practice may not have been widespread, but certainly more Democrats voted in the Republican primary than the other way around.

Other open primary states, which also tend to favor Trump on the Republican side, are coming up this week in Illinois, Missouri and Ohio.

Overall, the important thing about Michigan for Sanders is the very fact that his win was unexpected. Because the race was so close and Clinton completely washed him out in Mississippi, she has an even stronger lead in the delegate race than she did before Tuesday — but the narrative around his surprise win could give his campaign a big boost, particularly in fundraising.

If Sanders' successes with the trade argument and African-American voters hold up in some of the other large Midwestern states that have yet to vote (Ohio and Illinois vote on March 15), he could be back in the game.

But Sanders still has a very tough climb ahead of him, given Clinton's delegate domination. Clinton campaign manager Robby Mook pointed in a press call on Wednesday afternoon that the former secretary of state now has "well over 200" more delegates than Sanders does, noting that that's a bigger margin that President Obama ever had over Clinton in 2008.

While a surprise win will embolden Sanders supporters, it also serves as a reminder to Clinton's backers not to sit out an election just because it looks like she'll win.