Bernie Sanders pulled off a shocking upset victory in Michigan on Tuesday, overcoming a double-digit deficit in the polls to win his largest state yet.

Sanders had gambled big on Michigan, pouring in resources and time with the expectation that the state would be receptive to his populist economic message and criticism of American free trade agreements.

That bet appears to have paid off in a big way. Sanders's win in Michigan on Tuesday — the Associated Press and MSNBC called the race for Sanders around 11:30 pm — was powered largely by his huge advantage among the white working-class voters and young voters who have been crucial to his coalition, according to initial exit polls.

Sanders's win in Michigan is good for him not just because he will pick up around half of the state's 130 delegates. It also suggests Sanders has a real shot at many of the delegate-rich states — like Ohio, Illinois, and Wisconsin — that lie ahead.

The Sanders win is particularly surprising because it so dramatically contradicted the polls, which almost uniformly had Clinton running far ahead of the Vermont senator in Michigan. Earlier in the night, FiveThirtyEight's Nate Silver said that a Sanders win in Michigan would "count as among the greatest polling errors in primary history."

Why experts think Bernie Sanders is still far from the nomination

Of course, Sanders continues to face steep obstacles to the nomination. Even with his strong Michigan showing, he actually probably fell even further behind on Tuesday to Clinton in the metric that matters most: the delegates who determine the nomination.

The states in the Democratic primary aren't winner-take-all. Instead, the margin of victory is critical to racking up delegates, meaning a candidate needs a big margin in a state's popular vote to gain a significant margin in its available delegates.

Because of Clinton's huge victories across the South, she had amassed a big enough delegate lead — around 200 delegates — that most experts think Sanders will be unable to overcome it without landslide wins of his own.

"Even winning Michigan would not necessarily put [Sanders] on the path to be competitive for the nomination," said Matt Grossmann, director of the Institute for Public Policy and Social Research at Michigan State University, in an interview Tuesday morning. "He really needs to start winning places by 20 points. It's an uphill battle, there's no doubt about that."

Clinton won Mississippi by an 83-to-16-point vote margin, meaning she'll probably win the majority of the state's 36 delegates. With the closeness of the results in Michigan, Sanders may not get more than a handful more delegates than Clinton there — even if it's one of his biggest wins yet.

According to our updated delegate counts, Clinton got 93 delegates tonight and Sanders got 73:

Why Bernie Sanders's victory is still impressive and surprising

None of this should take anything away from the impressiveness of Sanders's win tonight.

The polling out of Michigan had not been close. Sanders was down by at least 10 points in every poll listed in the RealClearPolitics average. One showed Clinton up by 37 points this week.

Grossmann, whom I spoke to before any results had come out, said that his firm's polling showed Clinton and Sanders running closer than most of the others did.

"Some of these are automated polls, and automated polls can't call cellphones. All of Bernie's advantage is among people under 30," Grossmann said.

FiveThirtyEight's Harry Enten also noted that Sanders had only lost black voters by 32 percentage points — closing Clinton's margin of victory among African Americans in other states — and held "his own in the wealthier suburban counties" that broke for Clinton in other states.

There may be a broader takeaway here as well. Earlier today, I noted that Clinton had done well in states that supported President Barack Obama's policies, whereas Sanders won those seeking a more fundamental break. Tonight may be a sign that there's still a groundswell of discontent in Michigan with Democratic political leadership.