WASHINGTON - A federal judge in Texas ruled late Friday that core aspects of the Affordable Care Act, commonly known as Obamacare, are unconstitutional, a win for Republicans and the Trump administration that could leave those insured under the system in uncertain territory.

The 55-page ruling by U.S. District Court Judge Reed O’Connor in the Nothern District of Texas was issued just one day before open enrollment was set to end this year for President Barack Obama's signature legislative achievement.

O’Connor agreed with a coalition of Republicans that it was unconstitutional to mandate that individuals buy health insurance or be taxed for not complying. He said last year’s tax cut bill knocked the constitutional foundation from under Obamacare by eliminating a penalty for not having coverage.

"The court today finds the individual mandate is no longer fairly readable as an exercise of Congress's tax power and continues to be unsustainable under Congress's interstate commerce power," O’Connor wrote. "The court therefore finds the individual mandate, unmoored from a tax, is unconstitutional."

The ruling is expected to be appealed and likely will have no immediate impact on people who buy insurance coverage through federal or state marketplaces. Most consumers still can purchase 2019 coverage on the federal marketplace through Saturday.

But it raises the prospect of another lengthy court fight between Republican and Democratic state officials that could end up at the Supreme Court.

But if the ruling is upheld, it could have a sweeping impact on how millions of Americans get health insurance.

That means subsidies that people collect to buy health coverage would no longer be available. Medicaid program that have extended insurance coverage to millions of low income and working class American could be in jeopardy.

Also at risk is the health law’s popular provision that prevents health insurers from denying coverage to people based on pre-existing conditions. Before Affordable Care Act insurance coverage began in 2014, insurers routinely denied or limited coverage of individual based in existing medical conditions.

The Supreme Court has twice saved former the 2010 health care law, first in 2012 when it upheld the law's mandate that individuals buy insurance as a tax, then in 2015 when it upheld tax credits for low-income recipients in federal as well as state insurance exchanges.

President Donald Trump later ended federal payments to insurers for the subsidies they provide lower-income recipients.

The latest challenge stems from Congress' elimination of the penalty for not purchasing health insurance, which was included in the $1.5 trillion tax overhaul approved last December. Texas and 19 other states argued that the entire law was ruled constitutional based on that penalty, which the Supreme Court compared to a tax. It will disappear in 2019 under the tax law.

The Trump administration sided largely with those states but argued that only some provisions of the law should fall alongside the individual mandate. That would include coverage for pre-existing conditions. But a group of Republican senators are seeking to preserve at least part of that coverage if the law is struck down.

The Justice Department had urged the judge not to rule in the midst of the health law's open enrollment season or risk a chaotic situation. The federal enrollment period runs from Nov. 1 through Saturday, and into January in some states.

A central question in the case is whether Congress intended for the individual mandate and coverage for pre-existing conditions to be inseparable, as the Obama administration argued in 2012. Five years later, Congress specified that eliminating the penalty should not jeopardize the rest of the law.

The annual penalty for those who refuse to get health insurance is $695 or 2.5% of income, whichever is greater.

O'Connor previously has ruled against other aspects of the Affordable Care Act. His ruling, in this case, would block the law while it's being argued on the merits. But first, that ruling likely will be appealed by California and other states to the U.S. Court of Appeals for the 5th Circuit, which is dominated 11-5 by Republican presidents' nominees.

The lawsuit was brought by 20 Republican-led states. After Trump ordered the Justice Department to stop defending the health care law, a coalition of ACA-supporting states took up the defense.

O’Connor was appointed by President George W. Bush and has previously blocked other Obama-era policies.

Trump touted the ruling late Friday as a way forward for Congress to pass new health care legislation – something that is unlikely to happen as Democrats take control of the House of Representatives in January.

"As I predicted all along, Obamacare has been struck down as an UNCONSTITUTIONAL disaster!" the president said on Twitter. "Now Congress must pass a STRONG law that provides GREAT healthcare and protects pre-existing conditions. Mitch and Nancy, get it done!"

In another tweet, Trump called the ruling "great news for America!"

Democrats, on the other hand, pledged to appeal the ruling and said the Republican effort showed conservatives aim to strip protections for those with preexisting conditions, something the Affordable Care Act covers.

Rep. Nancy Pelosi, who is virtually assured of becoming House speaker in January, called the ruling "absurd" and vowed to intervene in the appeals process when Democrats take control of the House in January.

"Tonight’s district court ruling exposes the monstrous endgame of Republicans’ all-out assault on people with pre-existing conditions and Americans’ access to affordable health care," she said in a statement. "While the district court’s absurd ruling will be immediately appealed, Republicans are fully responsible for this cruel decision and for the fear they have struck into millions of families across America who are now in danger of losing their health coverage."

The White House, in a statement, said O’Connor's decision "vindicates" Trump's position that Obamacare is unconstitutional but added that while the lawsuit is being appealed, "the law remains in place" and health coverage will continue.

The Trump administration created new rules that allow insurers to sell bare-bones insurance plans that lack the consumer protections of Obamacare plans. Those short-term plans are usually less expensive, but they often don't cover the minimum set of benefits such as prescription drugs, mental health or maternity care that Obamacare plans must cover. And unlike Obamacare plans, they can also exclude or limit coverage based on pre-existing medical conditions.

Contributing: Associated Press