The U.S. Supreme Court threw out a discrimination finding against a Colorado baker who wouldn’t make a cake to celebrate a same-sex wedding, in a narrow ruling that doesn’t resolve broad constitutional questions about the dueling rights of gay people and business owners.

A seven-justice majority said the Colorado Civil Rights Commission finding in the baker’s case was tainted by animus toward religion. Writing for the court, Justice Anthony M. Kennedy pointed to one commissioner’s comments that religion had been...