Liberals said that a ruling by the five conservative, Republican-nominated justices to strike down the signature domestic achievement of a Democratic president and a Democratic-controlled Congress would come with an unmistakable partisan sheen.

But with Chief Justice John G. Roberts Jr. joining the four justices nominated by Democratic presidents to uphold the Affordable Care Act, the charges of a political deal have come from the right.

“The fact that this decision was apparently political, rather than legal, completely undermines its legitimacy as a precedent,” said Randy Barnett, the Georgetown Law Center professor who was at the heart of the legal strategy for challenging the law.

The Wall Street Journal’s editorial page initially denounced Thursday’s ruling and returned Monday even more outraged, saying that the decision “is far more dangerous, and far more political, even than it first appeared last week.”

Roberts, along with the conservative members of the court, rejected the Obama administration’s argument that Congress was empowered by the Constitution’s commerce clause to require that almost every American either obtain health insurance by 2014 or pay a penalty.

But over the objections of the conservatives, who wanted to strike down the entire law, Roberts joined the court’s liberals to say that the act was a valid exercise of Congress’s taxing power.

He said that even that may not be the best reading of the law but that the court must hold an act constitutional if a plausible argument can be made for it. He quoted Justice Oliver Wendell Holmes: “As between two possible interpretations of a statute, by one of which it would be unconstitutional and by the other valid, our plain duty is to adopt that which will save the Act.”

Ever since the decision, there has been speculation that Roberts at one point was aligned with the conservative justices. CBS’s Jan Crawford reported that Roberts changed his mind at some point after the arguments in late March and “withstood a month-long, desperate campaign to bring him back to his original position.”

The court’s inner workings are secret; Crawford attributed her report to “two sources with specific knowledge of the deliberations.”

The four justices who voted to strike down the entire law were Justices Antonin Scalia, Anthony M. Kennedy, Clarence Thomas and Samuel A. Alito Jr. The joint dissent they issued on the day of the decision was unusual because it did not follow the customary pattern of addressing the arguments made in the majority opinion.

And the four did not join the part of Roberts’s opinion that addressed the commerce clause, even though they essentially agreed with his assessment. Joining Roberts to uphold the law were Justices Ruth Bader Ginsburg, Stephen G. Breyer, Sonia Sotomayor and Elena Kagan.

The health-care law’s challengers were reflecting Monday on what might have been. At a forum at the libertarian Cato Institute, speakers both cheered holdings in the opinion that would seem to restrain the federal government’s power and lamented the narrow ruling that keeps the law in place.

Roberts is bearing the brunt of the criticism. Cato’s Ilya Shapiro said that the ruling was a “political decision dressed up in legal robes, judicially enacting a law Congress did not pass and would not have passed, all to ‘save’ the court to fight another day.”

Carrie Severino, legal counsel for the Judicial Crisis Network, said Roberts had succumbed to declarations by Obama and the left that the court would be seen as partisan if it struck down the law.