LOS ANGELES (MarketWatch) — The second landmark Supreme Court discussion questioning the viability of the Affordable Care Act had one notable departure from arguments made three years ago: the swing vote of Justice Anthony Kennedy this time appeared to be headed in favor of the controversial law.

Kennedy, who questioned the validity of the law in 2012 and ultimately voted against its individual mandate — a provision that was upheld nonetheless through a majority created by Chief Justice John Roberts and the court’s four liberal justices — seemed headed toward upholding medical-coverage subsidies in the 34 states that rely on the federal government’s HealthCare.gov exchange.

Investors saw that as good news for shares of hospital companies, which have benefited from Obamacare’s assurance that they will be compensated regardless of a patient’s income. By the close Wednesday, shares of HCA Holdings Inc. HCA, -3.56% , Tenet Healthcare Corp. THC, -5.20% and Community Health Systems Inc. CYH, +0.22% were each up around 6%. Other hospital operators gained as well, with LifePoint Hospitals Inc. US:LPNT climbing 3.6% and Universal Health Services up 2.7%.

The case before the court Wednesday, King v. Burwell, took issue with a four-word section of the 2010 legislation that says subsidies are available for programs bought via exchanges “established by the State.” Those challenging Obamacare say that section excludes the 34 states, and ultimately more than 7.5 million of those insured under the program, from receiving subsidies — aid which the bulk of those policyholders needs to afford premiums.

A ruling against the administration could unravel Obamacare. The court is expected to rule on the matter in June, although it could hand down a decision earlier.

According to The Wall Street Journal, Kennedy wondered aloud whether taking away subsidies in states that don’t set up exchanges would mean they would be being unfairly pressured to establish their own clearinghouses. Kennedy said he saw a “serious constitutional problem.”

In the 2012 Supreme Court ruling, justices decided the federal government couldn’t put undue pressure on states to adopt the Medicaid expansion that went hand-in-hand with the establishment of exchanges. Kennedy said on Wednesday that if states had known they would lose out on subsidies, they wouldn’t have decided to let the federal government run their exchanges.

The court’s four liberal justices also strongly challenged the petitioners and their attorney, Michael Carvin, while conservative justices took issue with government representatives.

Whether Kennedy’s arguments tip the scale in favor of Obamacare proponents and against the petitioners in the case remains to be seen. Courtroom observers, particularly those who are against the law, say no one should think the case is a slam dunk for the Obama administration.

“I think if they say that, they’re being a bit overly optimistic,” said Hans von Spakovsky, senior legal fellow for the conservative research group Heritage Foundation, adding that Kennedy is hard to read.

“Kennedy was asking tough questions of both sides,” von Spakovsky said. “I don’t know which way he’s going to go.”

Still, courtroom observers on the other side couldn’t hold back their optimism.

“I think the case for the government is very good,” said Brianne Gorod, appellate counsel for the Constitutional Accountability Center.

Solicitor General Donald Verrilli, arguing on behalf of the government and the Department of Health and Human Services, said the court in the past has ruled that laws must not be taken out of context, and that the entire law needs to be taken into consideration. Obamacare proponents have noted that another part of the law clearly allows for states to let the federal government run their insurance exchanges.

When Verrilli came under tough questioning from conservative justices Antonin Scalia and Samuel Alito, the jurists had no response to that argument, observers said.

“The government had a very forceful answer to all of their questions,” Gorod said.

Either way, it appears the vote will be as close as the 5-4 decision in 2012 that upheld Obamacare’s requirement that all U.S. citizens buy health insurance.

It is estimated that roughly two-thirds of the 11.6 million currently enrolled through state or federal exchanges in Obamacare are receiving subsidies. Without subsidies, many foresee enrollees unable to afford insurance.

Further, in the 34 states that use the federal exchange, the mandate requiring employers of 50 or more workers to provide insurance would be rendered moot because penalties don’t kick in unless at least one of their employees receives subsidies.

HHS Secretary Sylvia Mathews Burwell, the respondent in this case, says the government has no plan B if justices rule in favor of the petitioners. But many feel the administration will try to make it easier for states to set up exchanges should it lose this case.

Meanwhile, Republican lawmakers in both the House and Senate will be under pressure to keep those tax credits in place until they find a suitable alternative, at least through the 2016 election.