Centers and clinics established to persuade women to continue their pregnancies cannot be required to tell their patients about the availability of state-offered services, including abortion, a divided Supreme Court said Tuesday.

The court’s conservatives said a California law at issue probably violates the First Amendment. It required what are called crisis pregnancy centers — which offer prenatal care and help when the baby is born — to post notices or tell clients about the state’s services.

Justice Clarence Thomas wrote the 5-to-4 decision .

He said that the “government-drafted script” specifically mentions abortion — “the very practice that petitioners are devoted to opposing.”

“Requiring petitioners to inform women how they can obtain state-subsidized abortions, at the same time petitioners try to dissuade women from choosing that option . . . plainly alters the content of petitioners’ speech,” Thomas wrote.

He was joined by Chief Justice John G. Roberts Jr. and Justices Anthony M. Kennedy, Samuel A. Alito Jr. and Neil M. Gorsuch.

Justice Stephen G. Breyer wrote the dissent for the court’s liberals, and read parts of it from the bench.

He said the court has repeatedly upheld state laws that provide a script for doctors when they are counseling women seeking abortions.

“If a state can lawfully require a doctor to tell a woman seeking an abortion about adoption services, why should it not be able, as here, to require a medical counselor to tell a woman seeking prenatal care or other reproductive healthcare about childbirth and abortion services?” Breyer wrote.

“As the question suggests, there is no convincing reason to distinguish between information about adoption and information about abortion in this context,” he added.

Breyer was joined by Justices Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan.

The California legislature said it was moved to act because some centers trick women into thinking they provide contraceptive services, including abortion, and sometimes delay a woman until it is too late to schedule an abortion.

But the centers said the law violates their constitutional rights by forcing them to deliver a message that is antithetical to their mission of encouraging women to continue their pregnancies.

The California law at issue requires centers offering some medical services, such as ultrasound exams, to meet specific requirements and be licensed. They also must display or relay to a woman the state’s message:

“California has public programs that provide immediate free or low-cost access to comprehensive family planning services (including all FDA-approved methods of contraception), prenatal care, and abortion for eligible women. To determine whether you qualify, contact the county social services office.”

A clinic that does not offer medical services is required to post a sign and include in advertisements that it is “not licensed as a medical facility by the State of California and has no licensed medical provider who provides or directly supervises the provision of services.”

The Supreme Court majority also cast doubt on that portion of the law.

Thomas said it was a burden on centers — it requires advertisements in several languages — without good reason.

“California has not demonstrated any justification for the unlicensed notice that is more than purely hypothetical,” he wrote.

California said its messages take no position on abortion. It makes sense to require the centers to tell patients about the state’s services because that it is when women most need them, the state contends.

In their brief to the Supreme Court, the centers said that “forcing a pro-life group to advertise for abortion has to be unconstitutional.”

They said the law violates two “cardinal First Amendment principles: it targets disfavored speakers and compels them to deliver the state’s message. And it does so in the context of speech on a subject where there is profound moral and ideological disagreement.”

The Trump administration had taken the position that the sign provision for the licensed centers was unconstitutional. But it said the restrictions on the unlicensed centers should be upheld.

California Attorney General Xavier Becerra in a statement called the Supreme Court’s decision “unfortunate” and pledged to continue working “to ensure that Californians receive accurate information about their healthcare options.”

Abortion rights groups reacted more strongly.

Nancy Northup, president and chief executive of the Center for Reproductive Rights, said in a statement: “We disagree with the Court’s decision that fake health centers have a free speech right to dress up like medical centers and deceive pregnant women.”

She added: “This decision leaves unanswered the question of why the anti-choice movement relies on deceptive tactics like fake health centers to pursue their aim of denying the right to decide to end a pregnancy.”

The centers celebrated.

“No one should be forced by the government to express a message that violates their convictions, especially on deeply divisive subjects such as abortion,” said Michael Ferris of the Alliance Defending Freedom, which represented the National Institute of Family and Life Advocates.

“In this case, the government used its power to force pro-life pregnancy centers to provide free advertising for abortion. The Supreme Court said that the government can’t do that, and that it must respect pro-life beliefs.”

Although similar notification laws in Baltimore and other jurisdictions have been struck down, a unanimous panel of the U.S. Court of Appeals for the 9th Circuit upheld California’s act.

The case is National Institute of Family and Life Advocates v. Becerra.