WASHINGTON — The U.S. Supreme Court on Monday handed a victory to abortion rights advocates, striking down a Texas law imposing strict regulations on abortion doctors and facilities that its critics contended were specifically designed to shut down clinics.

The 5-3 ruling held that the Republican-backed 2013 law placed an undue burden on women exercising their constitutional right to end a pregnancy established in the landmark 1973 Roe v. Wade decision. The normally nine-justice court was one member short after the Feb. 13 death of conservative Justice Antonin Scalia, who consistently opposed abortion in past rulings.

Conservative Justice Anthony Kennedy joined liberal members of the court in ruling that both key provisions of the law violate a woman’s constitutional right to obtain an abortion.

Liberal Justice Stephen Breyer, writing for the court, said that the appeals court that upheld the law was wrong in its approach, noting that courts are required to “consider the burdens a law imposes on abortion access together with the benefits that those laws confer.”

Deferring to state legislatures over “questions of medical uncertainty is also inconsistent with this court’s case law,” Breyer added.

Three conservative justices — Chief Justice John Roberts, Justice Clarence Thomas and Justice Samuel Alito — dissented.

By setting a nationwide legal precedent that the two provisions in the Texas law were unconstitutional, the ruling imperils laws already in place in other states.

Texas had said its law, passed by a Republican-led Legislature and signed by a Republican governor in 2013, was aimed at protecting women’s health. The abortion providers had said the regulations were medically unnecessary and intended to shut down clinics. Since the law was passed, the number of abortion clinics in Texas, the second-most-populous U.S. state with about 27 million people, has dropped from 41 to 19.

“The decision erodes states’ lawmaking authority to safeguard the health and safety of women and subjects more innocent life to being lost,” Republican Texas Gov. Greg Abbott said. “Texas’ goal is to protect innocent life, while ensuring the highest health and safety standards for women.”

President Barack Obama, whose administration backed the abortion providers in the court challenge, said in a statement he was “pleased to see the Supreme Court protect women’s rights and health” and that restrictions like those in Texas “harm women’s health and place an unconstitutional obstacle in the path of a woman’s reproductive freedom.”

The Texas law required abortion doctors to have “admitting privileges,” a type of formal affiliation that can be hard to obtain, at a hospital within 30 miles of the clinic so they can treat patients needing surgery or other critical care.

The law also required clinic buildings to possess costly, hospital-grade facilities. These regulations covered numerous building features such as corridor width, the swinging motion of doors, floor tiles, parking spaces, elevator size, ventilation, electrical wiring, plumbing, floor tiling and even the angle that water flows from drinking fountains.

‘Substantial obstacle’

“We conclude that neither of these provisions offers medical benefits sufficient to justify the burdens upon access that each imposes,” Breyer wrote in the ruling. “Each places a substantial obstacle in the path of women seeking a pre-viability abortion, each constitutes an undue burden on abortion access, and each violates the federal Constitution.”

Alito said in his dissenting opinion that the court should have upheld the law on a legal technicality. He criticized the majority, saying that in striking down the law, the court “simply disregards basic rules that apply in all other cases.”

The last time the justices decided a major abortion case was nine years ago when they ruled 5-4 to uphold a federal law banning a late-term abortion procedure.

Abortion rights supporters hailed the ruling.

Amy Hagstrom Miller, founder and CEO of Whole Woman’s Health, which led the challenge to the Texas law, said, “Every day Whole Woman’s Health treats our patients with compassion, respect and dignity — and today the Supreme Court did the same. We’re thrilled that today justice was served and our clinics stay open.”

Presumptive Democratic presidential nominee Hillary Clinton on Twitter called the ruling “a victory for women in Texas and across America.”

“This fight isn’t over: The next president has to protect women’s health. Women won’t be ‘punished’ for exercising their basic rights,” she said, a dig at presumptive Republican presidential nominee Donald Trump, who once suggested women who get illegal abortions should face “some sort of punishment.” The presidential election is Nov. 8.

U.S. Rep. Chellie Pingree, D-Maine, who had signed onto an amicus brief in opposition to the Texas abortion law, also praised the court’s decision in a statement Monday morning.

“The intent of the Texas law was never making women safer; it was meant to restrict access safe, legal abortion. In doing so, the law would have forced millions of women to drive over a hundred miles to receive essential reproductive health care. I’m relieved the justices put a stop to it, overturning these unjust and unnecessary restrictions. More than just Texas, this decision tells states across the country that similarly restrictive laws will not stand. This is a huge victory for women’s health and rights,” Pingree said.

Maine Attorney General Janet Mills joined the chorus of supporters who praised the court’s decision. Mills had signed onto an amicus brief along with attorneys general from several other states in opposition to the regulations imposed on abortion providers in Texas.

“Today’s decision is a victory for women. The Texas clinic regulations that purported to protect women’s health did no such thing. We argued that these regulations were clearly designed to be a burden on the provision of women’s health and the Court found they were.” Mills said in a statement Monday.

U.S. Sen. Susan Collins, R-Maine, also supported the decision.

“I agree with today’s Supreme Court decision, which affirmed its previous rulings that a state cannot place an “undue burden” on a woman’s constitutional right to access a safe and legal abortion,” Collins stated.

Abortion opponents denounced the ruling.

“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,” Texas Attorney General Ken Paxton, a Republican, said in a statement.

Republican Texas Lt. Gov. Dan Patrick added that abortion clinics are now “free to ignore these basic safety standards and continue practicing under substandard conditions. By its ruling, the court held that the ability of abortion clinics to remain open — even under substandard conditions — outweighs the state’s ability to put women’s health and safety first.”

Some states have pursued a variety of restrictions on abortion, including banning certain types of procedures, prohibiting it after a certain number of weeks of gestation, requiring parental permission for girls until a certain age, imposing waiting periods or mandatory counseling, and others.

Americans remain closely divided over whether abortion should be legal. In a Reuters/Ipso online poll involving 6,769 U.S. adults conducted from June 3-22, 47 percent of respondents said abortion generally should be legal and 42 percent said it generally should be illegal.

Views on abortion in the United States have changed very little over the decades, according to historical polling data.