If the new health care law wasn’t enough of a mess before last week’s Supreme Court decision, that ruling actually added another layer of cost, complexity and political contentiousness to the bill.

By striking down part of the law that required states to expand their Medicaid programs, the court tossed a very hot potato into the laps of state lawmakers everywhere.

ObamaCare required states to increase eligibility for Medicaid to 133 percent of the poverty line, or roughly $30,000 per year for a family of four. The expansion would also make childless single men (a notoriously high-cost group) eligible for Medicaid for the first time. In all, about 40 percent of all the people projected to gain coverage under ObamaCare would do so via Medicaid.

But this imposed real costs on states. For example, the Medicaid expansion would cost New Jersey taxpayers roughly $35 billion over 10 years, and New Yorkers as much as $52 billion.

Not surprisingly, many states balked — and now the high court has agreed: Congress can’t strip all Medicaid funds from states that refuse the expansion, as the ObamaCare law threatened.

So what will state legislators do now?

If they agree to expand their Medicaid programs anyway, they’ll be choosing to pile new costs on their state budgets and new taxes on their constituents.

And if a state doesn’t expand its Medicaid program, most of those who would’ve been eligible for Medicaid will now become eligible for subsidies through ObamaCare’s health-insurance exchanges. And those subsidies are paid in full by the feds.

Thus, New York, for example, would shift most of that $52 billion in new costs back to the federal government.

Of course, if states do shift those costs back to the feds, that will cause the federal cost of ObamaCare to skyrocket. If every state were to refuse to expand its Medicaid program, the feds would save roughly $130 billion in their share of Medicaid costs in 2014, but would have to pay $230 billion more in new exchange-based subsidies — for a net added cost of $100 billion. And that’s just for the first year.

Remember, this is a law that already will cost as much as $2.7 trillion from 2014 to 2024, and will add more than $823 billion to the federal deficit — estimates that assumed state taxpayers would be picking up some Medicaid costs. How will Congress react if billions or perhaps trillions of dollars in new costs are added to the federal budget?

Here’s another complicating factor: Most states have not yet set up an exchange. Many, especially ones with Republican governors or legislatures, may refuse altogether. By most estimates, as few as 15 states are likely to have exchanges in operation by the 2014 deadline.

ObamaCare gives the feds the authority to step in, setting up and operating an exchange in any state that doesn’t set up its own — but there is reason to doubt that they have resources to do so in so many states.

Anyway, federal subsidies are available only through exchanges that the states set up. The feds can’t offer subsidies through a federally run exchange.

Thus, if states neither expanded Medicaid nor set up exchanges, that would effectively block most of ObamaCare’s new entitlement spending.

One last wrinkle: It is those subsidies that trigger the penalty under ObamaCare for employers who fail to provide workers with insurance. So states that don’t set up exchanges could also escape the “employer mandate.”

That is, ObamaCare requires employers with 50 or more workers to provide health insurance or pay a fine…er, tax. But that tax only kicks in if at least one employee qualifies for subsidies under the exchange. Since subsidies can only be provided via a state-authorized exchange, a state that refuses to set one up could end up blocking the employer mandate altogether. At the very least, expect some employers to sue on this point, leading to yet another Supreme Court challenge.

And if, as expected, ObamaCare drives up the cost of insurance, many employers could end up dropping their current health insurance. So the end result of all this could be even more uninsured than before the law passed.

In short, the Supreme Court’s ruling not only guaranteed that ObamaCare will be an issue in this fall’s federal elections; it dumped a mess in the laps of governors and state legislators, too.