Although the overall ruling is a victory for supporters of ObamaCare, the particulars of the Supreme Court's decision today are almost exactly the opposite of what most observers expected. It's like a ruling from Bizarro World.
The Court upheld the mandate—but as a tax rather than as a valid exercise of the Commerce Clause. Most of the lower-court judges, including Democratic appointees, who previously ruled on the case had rejected this argument, and the administration seemed to offer it half-heartedly. Indeed, not only is President Obama on record as insisting that the law is not a tax, but Democrats in Congress changed the text of the bill during the legislative process to ensure that the law's language did not refer the mandate as a tax. Indeed, the Court managed the neat trick of accepting the argument that the federal government can not regulate inactivity or create commerce in order to regulate it under the Constitution's Commerce Clause, but still upholding the validity of the law's mandate.
The Court ruled that the law's Medicaid expansion as constructed was coercive. Technically, Medicaid is a voluntary program, but states argued that the law's Medicaid expansion was coercive because it required states to either expand Medicaid as called for by the law or risk all previous and existing federal funding for the jointly funded health program, which represents a huge portion of all state budgets. Most observers, even those opposed to the law, believed this to be the weakest argument and the one with the least chance of convincing the Court. But the Court's ruling agrees with the states, declaring that "the threatened loss of over 10 percent of a State's overall budget is economic dragooning that leaves the States with no real option but to acquiesce in the Medicaid expansion." The Medicaid expansion isn't struck down, but states now have the right to opt out without risking existing federal Medicaid matching funds.
Chief Justice John Roberts sided with Supreme Court's liberal wing while Justice Anthony Kennedy sided fully with the high court's conservatives. Conventional wisdom prior to the ruling was that Chief Justice Roberts would only vote to uphold the law if there were already five votes to uphold. But aside from Roberts, there were only four votes to uphold the law, and Justice Kennedy, widely presumed to be the swing voter who would decide the case, sided with the court's conservative win in arguing both that the mandate was unconstitutional and that the law should be struck down in its entirety.