Washington: A federal judge in Texas struck down Friday the entire Affordable Care Act on the grounds that its mandate requiring people to buy health insurance is unconstitutional and the rest of the law cannot stand without it.

The ruling was over a lawsuit filed this year by a group of Republican governors and state attorneys general. A group of intervening states led by Democrats promised to appeal the decision, which will most likely not have any immediate effect. But it will almost certainly make its way to the Supreme Court, threatening the survival of the landmark health law and, with it, health coverage for millions of Americans, protections for people with pre-existing conditions and much more.

In his ruling Friday, Judge Reed O'Connor of US District Court in Fort Worth said that the individual mandate requiring people to have health insurance "can no longer be sustained as an exercise of Congress' tax power."

Accordingly, O'Connor, a George W. Bush appointee, said that "the individual mandate is unconstitutional" and the remaining provisions of the Affordable Care Act are invalid.

At issue was whether the health law's insurance mandate still compelled people to buy coverage after Congress reduced the penalty to zero dollars as part of the tax overhaul that President Donald Trump signed last December. When the Supreme Court upheld the mandate as constitutional in 2012, it was based on Congress' taxing power. Congress, the court said, could legally impose a tax penalty on people who do not have health insurance.

But in the new case, the plaintiffs, led by Texas, argued that with the penalty zeroed out, the individual mandate had become unconstitutional - and that the rest of the law could not be severed from it.

The Justice Department's response to the case was highly unusual: though it disagreed with the plaintiffs that the entire law should be struck down, it declined this year to defend not just the individual mandate, but the law's provisions that protect people with pre-existing conditions. That prompted a coalition of 16 states and the District of Columbia, led by California, to intervene and defend the law.

On Friday night, a spokeswoman for Xavier Becerra, the California attorney general, said California and the other defendant states would challenge the ruling with an appeal in the US Circuit Court of Appeals in New Orleans.

"Today's ruling is an assault on 133 million Americans with pre-existing conditions, on the 20 million Americans who rely on the ACA's consumer protections for health care, on America's faithful progress toward affordable health care for all Americans," Becerra said in a statement. "The ACA has already survived more than 70 unsuccessful repeal attempts and withstood scrutiny in the Supreme Court."

Trump, who has consistently sought the law's repeal and has weakened it through regulatory changes, posted a response to the ruling on Twitter late Friday: "As I predicted all along, Obamacare has been struck down as an UNCONSTITUTIONAL disaster! Now Congress must pass a STRONG law that provides GREAT healthcare and protects pre-existing conditions."

The White House, in a separate statement late Friday, said, "We expect this ruling will be appealed to the Supreme Court. Pending the appeal process, the law remains in place."

If O'Connor's decision ultimately stands, about 17 million Americans will lose their health insurance, according to the Urban Institute, a left-leaning think tank. That includes millions who gained coverage through the law's expansion of Medicaid, and millions more who receive subsidized private insurance through the law's online marketplaces.

Insurers will also no longer have to cover young adults up to age 26 under their parents' plans; annual and lifetime limits on coverage will again be permitted; and there will be no cap on out-of-pocket costs.

Also gone will be the law's popular protections for people with pre-existing conditions, which became a major talking point in the November midterm elections, as Democratic candidates constantly reminded voters that congressional Republicans had tried to repeal the law last year. For many, it became the central, often winning message of their campaign, and the new ruling bolsters their argument heading into the 2020 election cycle.

Without those protections, insurers could return to denying coverage to such people or to charging them more. They could also return to charging people more based on their age, gender or profession.

The Kaiser Family Foundation, a nonpartisan research organization, estimates that 52 million adults from 18 to 64, or 27 percent of that population, would be rejected for coverage under the practices that were in effect in most states before the Affordable Care Act.

"If this Texas decision on the ACA is upheld, it would throw the individual insurance market and the whole health care system into complete chaos," Larry Levitt, a senior vice president of the Kaiser Family Foundation, wrote on Twitter. "But, the case still has a long legal road to travel before that's an immediate threat."