The Affordable Care Act could be headed back to the Supreme Court for the third time after a federal judge in Texas ruled Friday that the law is unconstitutional.

Judge Reed O’Connor of the U.S. District Court for the Northern District of Texas issued the opinion in a lawsuit brought in February by Republican officials in 20 states led by Texas Attorney General Ken Paxton. Those officials contended that the entire law should be stricken because Congress earlier this year repealed the fines known as “shared responsibility payments” that people without health coverage had to pay under the Affordable Care Act’s individual mandate. O’Connor agreed.

“The court finds the individual mandate can no longer be fairly read as an exercise of Congress’s tax power and is still impermissible under the interstate commerce clause ― meaning the individual mandate is unconstitutional…. [T]he court finds the individual mandate is essential to and inseverable from the remainder of the ACA,” O’Connor wrote in his opinion.

If the ruling stands, the Affordable Care Act’s insurance regulations would disappear and, along with them, the health coverage for millions of people who gained private insurance or Medicaid coverage under the 2010 law signed by President Barack Obama. Specifically, the law’s guarantee of coverage for people regardless of their pre-existing conditions, financial assistance for private insurance, rules establishing a basic minimum set of benefits insurance policies must cover and more would vanish. Since O’Connor’s ruling throws out the entire statute, the rest of the ACA, such as its expansion of Medicaid to low-income adults, also is stricken.

In short, this ruling would deal severe damage to the American health care system. It also would eradicate one of Obama’s most significant accomplishments. According to an analysis by the Urban Institute, eliminating the Affordable Care Act would increase the national uninsured rate by 50 percent and lead to more than 17 million people losing health coverage.

President Donald Trump celebrated the ruling in a pair of Twitter posts Friday night. “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,” he wrote in one post. In another Trump wrote, “Great news for America!”

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. Mitch and Nancy, get it done! — Donald J. Trump (@realDonaldTrump) December 15, 2018

O’Connor’s ruling does not include a stay to delay it from taking effect, so the Affordable Care Act is now technically unconstitutional. The ruling will be appealed, however, making it unlikely that the law’s health insurance markets, funding and regulations will immediately go away.

“Today’s ruling is an assault on 133 million Americans with preexisting conditions, on the 20 million Americans who rely on the ACA for health care, and on America’s faithful progress toward affordable health care for all Americans,” California Attorney General Xavier Becerra said in a news release. “The ACA has already survived more than 70 unsuccessful repeal attempts and withstood scrutiny in the Supreme Court. Today’s misguided ruling will not deter us: Our coalition will continue to fight in court for the health and wellbeing of all Americans.” Becerra led the team of Democratic state attorneys general who defended the Affordable Care Act in the case.

Rich Pedroncelli/ASSOCIATED PRESS California Attorney General Xavier Becerra said, "Today’s misguided ruling will not deter us: Our coalition will continue to fight in court for the health and wellbeing of all Americans.”

“The question of constitutionality is straightforward: Is the individual mandate a constitutional exercise of Congress’s enumerated powers when the shared-responsibility payment is zero?” O’Connor wrote. “Because the Supreme Court upheld the individual mandate under Congress’s tax power, the Court will begin there before proceeding to an interstate commerce clause analysis. The court finds that both plain text and Supreme Court precedent dictate that the individual mandate is unconstitutional under either provision.”

Liberal and conservative legal scholars alike mostly dismissed the lawsuit, known as Texas v. Azar, as unserious and unsound, making O’Connor’s ruling somewhat surprising. AARP, along with the American Medical Association, the American Hospital Association, America’s Health Insurance Plans and other health care groups opposed the suit. So did a bipartisan group of nine governors.

During oral arguments in September from the GOP officials, the U.S. Justice Department and lawyers for a group of Democratic officials from 16 states and the District of Columbia, O’Connor appeared to side with the plaintiffs. President George W. Bush nominated O’Connor to the court in 2007.

The plaintiffs’ case was based on an interpretation of the Supreme Court ruling that upheld the individual mandate as constitutional in 2012 and the Obama administration’s arguments that the policy shouldn’t be struck down.

Obama’s Justice Department maintained that the mandate went hand-in-hand with the rules protecting people with pre-existing conditions and the insurance subsidies the law provides, and that the mandate could not be eliminated without scrapping the entire law. Chief Justice John Roberts based his majority opinion on the case in part on this line of reasoning when he wrote that the mandate is constitutional as part of Congress’ power to tax.

Congress eliminated the individual mandate’s penalties as part of the tax law President Donald Trump enacted earlier this year. Because there are no longer tax penalties associated with the Affordable Care Act and because the Obama administration argued the entire law must stand or fall on that basis, the GOP officials argued Roberts’ ruling no longer protects the law.

O’Connor found this persuasive, which he appeared to indicate during oral arguments. He cited the Roberts ruling, the Obama administration’s defense in the 2012 lawsuit and his interpretation of congressional intent when lawmakers passed the ACA in 2010 and when they repealed the mandate fines this year.

The Democratic state attorneys general defending the case argued, in effect, that congressional intent in 2010 doesn’t matter because Congress revisited the issue in 2017, when it passed the tax bill eliminating the mandate penalties. Congress understood very well that it would affect the health care law ― the issue was part of the debate ― and decided to do so anyway, the attorneys general said.

A wide variety of experts, including many critical of the Affordable Care Act in the past, found that line of argument persuasive. O’Connor did not. He said that it was a “fool’s errand” to consider what Congress did in 2017, because that was a debate about a tax bill, not the health care bill itself.

Trump’s Justice Department refused to defend the law in court in defiance of the federal government’s normal practice when a federal statute is challenged. Instead, Attorney General Jeff Sessions and his department argued that the court should eliminate only the provisions of the Affordable Care Act that protect people with pre-existing conditions. The Justice Department also asked the judge to delay the effectiveness of the ruling until after the close of this year’s open enrollment period on the health insurance exchanges, which ends Saturday.

The Trump administration official who oversees the exchanges confirmed Friday night that the federal government will continue to enforce the Affordable Care Act while O’Connor’s ruling is being appealed. “The recent federal court decision is still moving through the courts, and the exchanges are still open for business and we will continue with open enrollment. There is no impact to current coverage or coverage in a 2019 plan,” Seema Verma, administrator of the Centers for Medicare and Medicaid Services, wrote on Twitter.

Three career Justice Department attorneys removed themselves from the case shortly before the department took this position. Days later, a veteran Justice lawyer actually resigned, although he did not specify that this case was the reason why.

Because the federal government declined to defend its own law, O’Connor permitted Becerra and the other Democrats to argue on behalf of the Affordable Care Act instead. These officials emphasized that if Congress had wanted to repeal the entire law, it would have done so, but legislators merely did away with the mandate penalties.

Republican officials from Alabama, Arkansas, Arizona, Florida, Georgia, Indiana, Kansas, Louisiana, Maine, Mississippi, Missouri, Nebraska, North Dakota, South Carolina, South Dakota, Tennessee, Texas, Utah, West Virginia and Wisconsin filed the lawsuit.

Democratic officials from California, Connecticut, Delaware, Hawaii, Illinois, Kentucky, Massachusetts, Minnesota, New Jersey, New York, North Carolina, Oregon, Rhode Island, Vermont, Virginia, Washington and the District of Columbia defended the law.

Jonathan Cohn contributed to this article.

This article has been republished with comment from President Trump.