In a blow to commercial animal breeders and brokers, California pet stores will soon have to get their puppies, kittens and rabbits from shelters and rescue centers only.

Individuals can still buy from private breeders. But beginning in January 2019, it will be illegal for stores to do so. Violators will face a fine of $500.

The bill, A.B. 485, had strong support from several animal welfare organizations, which cheered it as a blow to “puppy mills” and “kitten factories” that mass produce animals for sale, often in inhumane conditions. It was written by two California Assembly members, Patrick O’Donnell and Matt Dababneh, both Democrats, and signed into law on Friday by Gov. Jerry Brown.

California is the first state to pass such legislation, though it is following dozens of its own cities and jurisdictions, which have passed similar measures on a smaller scale.