The opinion by U.S. District Judge Reed O'Connor overturns all of the sprawling law nationwide.

The ruling came on the eve of the deadline Saturday for Americans to sign up for coverage in the federal insurance exchange created under the law. If the ruling stands, it would create widespread disruption across the U.S. health-care system - from no-charge preventive services for older Americans on Medicare to the expansion of Medicaid in most states, to the shape of the Indian Health Service - in all, hundreds of provisions in the law that was a prized domestic achievement of President Barack Obama.

President Donald Trump, who has made the dismantling of the ACA a chief goal since his campaign, swiftly tweeted his pleasure at the opinion. "As I predicted all along, Obamacare has been struck down as an UNCONSTITUTIONAL disaster!" the president wrote just after 9 p.m. "Now Congress must pass a STRONG law that provides GREAT healthcare and protects pre-existing conditions."

Later, the White House issued a statement on the ruling, saying: "We expect this ruling will be appealed to the Supreme Court. Pending the appeal process, the law remains in place."

For their part, congressional Democrats, who defended the law and its protections for people with preexisting medical problems as a major theme leading up to last month's midterm elections, lambasted the Texas judge and portrayed themselves as champions of American health-care consumers.

House Minority Leader Nancy Pelosi, D-Calif., who is expected to become speaker next month, issued a statement that said: "When House Democrats take the gavel, the House of Representatives will move swiftly to formally intervene in the appeals process to uphold the life-saving protections for people with pre-existing conditions and reject Republicans' effort to destroy the Affordable Care Act."

A spokeswoman for California Attorney General Xavier Becerra, D, who leads a group of states opposing the lawsuit, said that the Democratic defenders of the law are ready to challenge the ruling in the U.S. Court of Appeals for the 5th Circuit.

It was not immediately clear what the legal path will be from here. Technically, O'Connor granted summary judgment to the lawsuit's plaintiffs - the Texas attorney general, with support from 18 GOP counterparts and a governor. Because the judge did not grant an injunction, as the plaintiffs had asked for, "it's unclear whether this is a final judgment, whether it's appealable, whether it can be stayed," said Timothy Jost, a health-law expert who is a professor emeritus at Washington and Lee University. Jost, an ACA proponent, predicted that a stay would lock in the law during appeals, saying that, otherwise, "it's breathtaking what [O'Connor]'s doing here on a Friday night after the courts closed."

Major segments of the health-care industry also decried the ruling. "The judge got it wrong," said Charles "Chip" Kahn III, president of the Federation of American Hospitals. "This ruling would have a devastating impact on the patients we serve and the nation's health-care system as a whole. . . . Having this decision come in the closing hours of open enrollment also sows seeds of unnecessary confusion."

"Today's decision is an unfortunate step backward for our health system that is contrary to overwhelming public sentiment," said Barbara McAneny, president of the American Medical Association. "No one wants to go back to the days of 20 percent of the population uninsured and fewer patient protections, but this decision will move us in that direction."

And calling the opinion "misguided and wrong," America's Health Insurance Plans, the industry's main trade group, sought to reassure consumers that their health coverage would remain "strong and stable" while the ruling is appealed.

Since the lawsuit was filed in January, many health-law specialists have viewed its logic as weak but nevertheless have regarded the case as the greatest looming legal threat to the 2010 law, which has been on the GOP's whipping post ever since and assailed repeatedly in the courts.

The Supreme Court upheld the law as constitutional in 2012 and 2015, though the first of those opinions struck down the ACA's provision that was to expand Medicaid nationwide, letting each state choose instead. No matter how O'Connor ruled, legal experts have been forecasting that the Texas case would be appealed and could well place the law again before the high court, giving its conservative newest member, Justice Brett M. Kavanaugh, a first opportunity to take part.

O'Connor is a conservative judge on the U.S. District Court for the Northern District of Texas. He was appointed by President George W. Bush. O'Connor ruled once before on an issue arising from the ACA, issuing a nationwide injunction two years ago on an Obama administration rule that forbade health-care providers from discriminating based on gender identity.

And in June, the administration took the unusual step of telling the court that it will not defend the ACA against this latest challenge. Typically, the executive branches argues to uphold existing statutes in court cases.

The lawsuit was initiated by Texas Attorney General Ken Paxton, who describes himself as a tea party conservative. The plaintiffs argue that the entire ACA is invalid. They trace their argument to the Supreme Court's 2012 ruling in which Chief Justice John Roberts Jr. wrote for the majority that the penalty the law created for Americans who do not carry health insurance is constitutional because Congress "does have the power to impose a tax on those without health insurance."

As part of a tax overhaul a year ago, congressional Republicans pushed through a change in which that ACA penalty will be eliminated, starting in January. The lawsuit argues that, with the enforcement of the insurance requirement gone, there is no longer a tax so the law no longer is constitutional.

"Once the heart of the ACA - the individual mandate - is declared unconstitutional, the remainder of the ACA must also fall," the lawsuit said.

In his 55-page opinion, O'Connor agrees. He writes that the individual mandate is unconstitutional, saying that it "can no longer be fairly read as an exercise of Congress' tax power."

The judge also concludes that this insurance requirement "is essential to and inseverable from the remainder of the ACA."

The opinion goes beyond the administration's legal position in the case. In a June court brief and an accompanying letter to congressional leaders, Justice Department officials contended that, once the insurance mandate's penalty is gone next month, that move will invalidate the ACA's consumer protections, such as its ban on charging more or refusing to cover people with preexisting medical conditions. But the administration argued that many other parts of the law could be considered legally distinct and thus can continue.

Just before the brief's deadline, three Justice attorneys involved with the case withdrew from it.

In the letter to Congress, then-Attorney General Jeff Sessions said that Justice was taking this position "with the approval of the president of the United States." Trump has vowed since his campaign to dismantle the law, a main domestic achievement of his predecessor, and the administration has been taking steps on its own to foster alternative insurance that tends to be less expensive because it skirts ACA requirements.

The lawsuit has been opposed by a coalition of 17 Democratic attorneys general, led by California's Becerra, a former congressman. The Democrats contend that while the Republican tax law will eliminate the federal penalty for being uninsured, it does not negate the ACA's constitutionality.

"Today's misguided ruling will not deter us. Our coalition will continue to fight in court for the health and well being for all Americans," Becerra said in a statement Friday night after the ruling.

During oral arguments in September, O'Connor asked more pointed questions of the Democratic attorneys general than of the Republicans.

The midterm elections last month have altered the political map in the case. In Wisconsin, an incoming Democratic attorney general, Josh Kaul, campaigned on a promise to withdraw the state from the lawsuit, but Wisconsin's Republican legislature and outgoing Gov. Scott Walker, R, have tried in a lame-duck session to block his ability to do that. In Maine, outgoing Gov. Paul LePage, R, joined the lawsuit, but the state attorney general's office told the court last month that the governor did not have power to do so on his own.

Paxton issued a statement praising the ruling, saying that it "halts an unconstitutional exertion of federal power over the American health care system" so that Congress can have "the opportunity to replace the failed social experiment with a plan that ensures Texans and all Americans will again have greater choice about what health coverage they need and who will be their doctor."

First published in The Washington Post.