SAN FRANCISCO — A federal appeals court has rejected a lawsuit that aimed to legalize prostitution in California.

The 9th U.S. Circuit Court of Appeals said Wednesday that the relationship between a prostitute and a client is not an intimate association protected by the U.S. Constitution.

A three-judge panel of the court ruled that California had legitimate reasons for criminalizing prostitution, including discouraging human trafficking and violence against women. The judges upheld a lower-court ruling.

The decision came in a lawsuit against several California district attorneys and the state’s attorney general. It was filed in 2015 by a San Francisco-based group that includes former sex workers.

An email to an attorney for the group wasn’t immediately returned.