The Supreme Court kept the Affordable Care Act alive Thursday, ruling in a 7-2 decision that Texas and 17 other states – plus two individuals – lacked standing to challenge its constitutionality.

The states had argued that the law's individual mandate was unconstitutional once it no longer carried a penalty because it had been justified as falling under the congressional power of taxation. They also claimed that the rest of the law could not survive without the mandate.

BIDEN ADMIN TELLS SUPREME COURT OBAMACARE IS CONSTITUTIONAL, A REVERSAL OF TRUMP'S DOJ STANCE

The court ruled that because the plaintiffs had not demonstrated any past or future harm, they were not in a position to bring the claim.

"We do not reach these questions of the Act’s validity, however, for Texas and the other plaintiffs in this suit lack the standing necessary to raise them," Justice Stephen Breyer wrote in the court's opinion.

Regarding the individual plaintiffs, Breyer noted that the lack of penalty makes the individual mandate provision of the law unenforceable, thus removing any damage.

"To find standing here to attack an unenforceable statutory provision would allow a federal court to issue what would amount to ‘an advisory opinion without the possibility of any judicial relief,’" he wrote.

As for Texas and the other states, Breyer said they "have failed to show that the challenged minimum essential coverage provision, without any prospect of penalty, will harm them by leading more individuals to enroll in these programs."

MSNBC'S JOY REID CLAIMS ‘EVIL’ MITCH MCCONNELL PLANNING TO PACK SCOTUS WITH CONSERVATIVE JUSTICES

The decision reverses lower courts who had ruled that the plaintiffs did have standing, and that the individual mandate was unconstitutional without the penalty, which had been lowered to zero under the Trump administration. A federal district court ruled that without the mandate, the rest of the law could not survive, but a court of appeals ruled that it could remain.

With the Supreme Court's ruling, the entirety of ObamaCare remains in place. Democrats had claimed that the court was sure to scrap the Affordable Care Act, commonly known as ObamaCare, if Justice Amy Coney Barrett was confirmed to the Supreme Court. Barrett, the third justice appointed by former President Donald Trump, was among the majority who voted in the law’s favor.

CLICK HERE TO GET THE FOX NEWS APP

Justice Samuel Alito, in a dissent joined by Justice Neil Gorsuch, railed against the majority’s decision in what he called "the third installment in our epic Affordable Care Act trilogy[.]" Alito asserted that, like in previous ObamaCare cases, the court stretched to find a way to keep the law in place.

"No one can fail to be impressed by the lengths to which this Court has been willing to go to defend the ACA against all threats," Alito wrote. "A penalty is a tax. The United States is a State. And 18 States who bear costly burdens under the ACA cannot even get a foot in the door to raise a constitutional challenge. So a tax that does not tax is allowed to stand and support one of the biggest Government programs in our Nation’s history. Fans of judicial inventiveness will applaud once again."

Fox News' Bill Mears and Shannon Bream contributed to this report.