Supreme Court justices on Tuesday indicated that a California law requiring antiabortion pregnancy centers in California to notify women that the state provides free or low-cost health care, contraception services and abortion could violate free speech rights.

Even some of the court’s liberal justices were concerned that the state had drawn the law to target clinics that encourage women to continue their pregnancies, and subjected only them to the requirements.

“If it has been ‘gerrymandered,’ that’s a serious issue,” said Justice Elena Kagan, a consistent liberal vote on the court, comparing the California law to the practice of manipulating political boundaries to favor a party or candidate.

That would mean the state is saying “we have these general disclosure requirements, but we don’t really want to apply them generally, we just want to apply them to some speakers whose speech we don’t much like,” she said.

The state said it wanted to make sure poor women in the state know about the services the government offers and also to counter “fake” clinics that seem to offer all pregnancy-related services, including abortion, but really mean only to persuade women to continue their pregnancies.

The clinics say the state is requiring them to deliver an abortion message at odds with their very purpose.

“California took aim at pro-life pregnancy centers by compelling licensed centers to point the way to an abortion and imposing onerous advertising rules on unlicensed centers that do not provide ultrasounds or any other medical services,” said Michael P. Farris, an attorney for the legal organization Alliance Defending Freedom, which represents some of the more than 200 antiabortion pregnancy centers in the state.

There are thousands more across the country, far outnumbering clinics that perform abortions.

California requires that pregnancy clinics that offer some medical services, such as ultrasound exams, meet specific requirements and be licensed. Those that do not are unlicensed, and the state wants them to make it clear that no medical personnel are on the premises.

The law at issue requires licensed centers to 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 second part of the law requires an unlicensed clinic 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.”

Justice Anthony M. Kennedy said that the latter requirement would apply to a facility that wanted to advertise itself with only two words: “Choose Life.”

If it must also print the state’s message — in as many as 13 languages in certain parts of California — that overwhelms its own message, Kennedy said.

“This is an undue burden in that instance, and that should suffice to invalidate the statute,” he said.

Kennedy is usually the deciding vote when it comes to ideologically divisive issues, and joined the court’s liberals in 2016 in striking down a Texas law regulating abortion clinics as too much of a burden on a woman’s right to abortion.

But his questions Tuesday were almost uniformly hostile to the law, and he was even short with other justices who seemed to defend it.

Justice Sonia Sotomayor told Farris that she had visited the website for one of the clinics and that its advertisements gave all appearances of offering medical advice and services. It showed a woman who appeared to be a nurse standing by medical equipment, and it promised information on abortion. It was just the kind of clinic the state said was misleading.

“If a reasonable person could look at this website and think that you’re giving medical advice, would the unlicensed notice be wrong?” Sotomayor asked Farris.

But Kennedy criticized the question. “Well, in this case I didn’t go beyond the record to look on the Internet because I don’t think we should do that,” he said.

Some of the liberal justices pointed to the Supreme Court’s 1992 decision affirming abortion rights. It nevertheless approved a Pennsylvania law requiring doctors discussing abortion with a woman to give them information about child support and other services should they continue the pregnancy.

“They’re really the exact flip side of the requirements in this case,” Kagan said.

But Farris said that there is a significant difference between a doctor consulting about a medical procedure and his clients only providing counseling.

Justice Stephen G. Breyer was not satisfied. “In law, what’s sauce for the goose is sauce for the gander,” Breyer said, adding that “if a pro-life state can tell a doctor you have to tell people about adoption, why can’t a pro-choice state tell a doctor, a facility, whatever it is, you have to tell people about abortion?”

California Deputy Solicitor General Joshua A. Klein said the state was only “promoting informed choice” for pregnant women who might not know that the state provides services to the poor — pre­natal care as well as abortion.

“The law empowers the woman by explaining that her financial circumstance does not make her unable to access alternative and supplemental care,” he said.

But Justice Neil M. Gorsuch said the state could do that itself.

“If it’s about just ensuring that everyone has full information about their options, why should the state free-ride on a limited number of clinics to provide that information?” Gorsuch said.

Justice Ruth Bader Ginsburg tried out a compromise that would not save California’s law but could be the model for replacement legislation.

She suggested that it would be constitutional for a state to require clinics to clearly list which services they offer so that a woman does not enter a clinic thinking it is something it is not.

“Like on food, you have to list all the ingredients,” Ginsburg said.

Jeffrey B. Wall, deputy solicitor general at the Justice Department, said that such a fix would seem to be constitutional. The Trump administration largely backed the clinics in the challenge.

While 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.