California lawmakers gave consumers unprecedented protections for their data and imposed tough restrictions on the tech industry, potentially establishing a privacy template for the rest of the nation.

The law, which was rushed through the legislature this week and signed by Gov. Jerry Brown on Thursday, broadens the definition of what constitutes personal information and gives California consumers the right to prohibit the sale of personal data to third parties and opt out of sharing it altogether. The bill applies to internet giants such as Facebook Inc. and Alphabet Inc.’s Google but also will affect businesses of any size that collect data on their customers.

Ashkan Soltani, a digital researcher and former chief technologist for the Federal Trade Commission, said the regulations are the first of their kind in the U.S.

While the law only applies to consumers in California, tech companies will likely shift their policies to conform to the new law given the complexity of carving out conflicting standards. It may also spur Congress to consider federal legislation, coming after multiple hearings in which legislators peppered industry executives with questions about whether they were taking data privacy seriously enough.

The bill doesn’t go into effect until 2020 and could still be amended. It is almost certain that major tech firms will lobby heavily to get certain concessions, and an industry group said Thursday that it would push for changes.

By passing the bill, the legislature headed off a more restrictive ballot initiative that recently qualified to appear before California voters in November. The ballot initiative was strongly opposed by most of the tech industry, which broadly viewed the legislation as the lesser of two evils.

Continue reading this story in the Wall Street Journal.