The Supreme Court, by a 5-3 vote, ruled in favor of abortion rights in a major case challenging an anti-abortion law passed in Texas. The majority opinion, written by Justice Stephen Breyer, struck down the legislation mandating clinics have admitting privileges with local hospitals and requiring they meet the same standards as surgical centers.

“We conclude that neither of these provisions offers medical benefits sufficient to justify the burdens upon access that each imposes,” Breyer wrote. He said that the restrictions placed “a substantial obstacle in the path of women seeking a previability abortion,” amounted to an undue burden on abortion access,” and were violations of the U.S. Constitution. He was joined by Justices Anthony Kennedy, Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan.

Ginsburg wrote an additional opinion concurring with the majority. Justice Samuel Alito wrote a dissenting opinion, joined by Chief Justice John Roberts and Justice Clarence Thomas, who also wrote his own dissent.

The decision is a major victory for abortion rights advocates, who had argued the laws were not meant to protect women’s health, as the state claimed, but rather sought to limit abortion access. Other states have passed laws similar to Texas’ and their legality is now in question thanks to Monday’s ruling.

The case, Whole Woman’s Health v. Hellerstedt, was brought by abortion providers in Texas who challenged the omnibus abortion bill the state passed in 2013. It required that clinics maintain facilities akin to mini-hospitals and mandated providers attain a special relationship with local hospitals. Only some of those provisions were part of the Supreme Court challenge, but the case was seen as an opportunity for the court to clarify at what point a restriction on abortions becomes a significant burden on a woman’s access to the procedure.

Defenders of the law said the restrictions would protect women’s health, while the challengers argued they weren’t necessary — and even had adverse effects on women — and the law was targeted at closing clinics.

The challengers had some success blocking the regulations at a district court level. However, the conservative 5th U.S. Circuit Court of Appeals has largely sided with the state. The Supreme Court’s decision Monday overturned the appeals court ruling upholding the two anti-abortion provisions.

The legislation had caused a large swath of clinics to close in the state, which Breyer noted in his opinion.

“More fundamentally, in the face of no threat to women’s health, Texas seeks to force women to travel long distances to get abortions in crammed-to-capacity superfacilities,” Breyer said. “Patients seeking these services are less likely to get the kind of individualized attention, serious conversation, and emotional support that doctors at less taxed facilities may have offered.”

The case is a sequel to the 1992 Supreme Court decision Casey v. Planned Parenthood, which set the legal standard for the constitutionality of abortion restrictions, i.e., the burdens a restriction imposes on abortion access versus the restriction’s benefits. Breyer pushed back at the idea that the courts should leave the question of whether a law was medically beneficial to the legislature.

“Instead, the Court, when determining the constitutionality of laws regulating abortion procedures, has placed considerable weight upon evidence and argument presented in judicial proceedings,” he said.

In her concurrence, Ginsburg said that it was “beyond rational” to argue that the law, also known as HB2, would protect women’s health and argued restricting safe and legal abortion access would lead women to seek the procedure from riskier, unlicensed practitioners.

Meanwhile, Thomas, in dissenting from the majority decision, accused the court of “applying different rules to different constitutional rights— especially the putative right to abortion.”

Likewise, Alito, in his own dissent, said the majority “disregards basic rules that apply in all other cases.”

Amy Hagstrom Miller — the CEO and founder of Whole Woman’s Health and abortion provider who brought the case — said in a statement that she was “thrilled that today justice was served and our clinics stay open.”

“Every day Whole Woman’s Health treats our patients with compassion, respect and dignity—and today the Supreme Court did the same,” Miller said.

Ken Paxton, the Republican Texas Attorney General who was defending the law, said in a statement the Supreme Court ruling was disappointing.

“HB2 was an effort to improve minimum safety standards and ensure capable care for Texas women. It’s exceedingly unfortunate that the court has taken the ability to protect women’s health out of the hands of Texas citizens and their duly-elected representatives,” he said.

Read the opinion below: