The U.S. Supreme Court’s 2003 ruling that declared a constitutional right to “intimate conduct” such as gay sex didn’t apply to sex for sale, a federal appeals court ruled Wednesday in upholding California’s 146-year-old ban on prostitution.

Three former prostitutes, a would-be client and the Erotic Service Providers Legal, Educational and Research Project had argued that the high court, in striking down state laws against gay or lesbian sexual activity, recognized an adult’s right to engage in consensual sex without state interference. They maintained that the ruling extended to adults who consent to sex for a price.

A panel of the Ninth U.S. Circuit Court of Appeals in San Francisco seemed receptive to that argument at a hearing in October, suggesting that the 1872 state ban might need closer scrutiny.

One panel member said prostitution had been historically subjected to the same sort of moral disapproval that had once condemned gay sex, and might be more acceptable under the Supreme Court’s current view of individual rights. Another asked why it should be “illegal to sell something that it’s legal to give away.”

But in a 3-0 ruling Wednesday, the panel ruled that the Supreme Court had not legalized prostitution with its 2003 decision.

Although the scope of the ruling was not clear, the Supreme Court specified that the gay sex case “does not involve ... prostitution,” Jane Restani, a judge of the U.S. Court of International Trade temporarily assigned to the appeals court, wrote in the panel’s decision.

That means the California law is constitutional as long as the state can show a rational basis for it, Restani said, noting that federal courts since 2003 have upheld prostitution laws in other states. She said the state had presented a number of legitimate reasons for prohibiting commercial sex, including “discouraging human trafficking and violence against women, discouraging illegal drug use, and preventing contagious and infectious diseases.”

The Constitution protects “freedom of intimate association,” Restani said, but that right extends only to “highly personal relationships” and not a prostitute’s relationship with a client, which lasts — as the court observed in another case 20 years ago — “only as long as the client is willing to pay the fee.”

“Banning the commodification of sex is a substantial policy goal that all states but Nevada have chosen to adopt,” Restani said. The ruling upheld a 2016 decision by U.S. District Judge Jeffrey White of Oakland.

H. Louis Sirkin, a lawyer for the Erotic Service Providers group and other plaintiffs, said they were disappointed by the ruling and would ask the full appeals court for a new hearing. Another plaintiffs’ lawyer, D. Gill Sperlein, said the justifications the state offered for the law would be served better if prostitution were legalized and regulated.

“I think any reasonable study would demonstrate that workers in an underground economy are more subject to human trafficking than a field of endeavor that’s in the light of day,” Sperlein said. “If it were decriminalized or entirely legal, then people would be more willing to come out of the shadows and uncover any kind of abuses.”

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter:@egelko