A bakery owner's lawyers argued that making the cakes violates her Christian beliefs and free religious expression.
The judge ruled the act of making cakes is protected as artistic expression and does not violate a state anti-discrimination law.
A similar case in Colorado is awaiting a US Supreme Court decision.
"A wedding cake is not just a cake in a Free Speech analysis. It is an artistic expression by the person making it that is to be used traditionally as a centerpiece in the celebration of a marriage," Kern County Superior Court Judge David Lampe wrote.