Businesses across the U.S. panned California’s new consumer-privacy legislation, saying it risked far-reaching damage to everything from retailers’ customer-loyalty programs to data gathering by Silicon Valley tech giants.

The bill, which was introduced one week before it was passed and was largely sold as a way to rein in big tech firms, sweeps up a range of businesses. It requires them to offer consumers options to opt out of sharing personal information, and it gives Californians the right to prohibit the sale of their...