SACRAMENTO, Calif.—California lawmakers passed landmark employment legislation that challenges the business model of “gig-economy” companies such as ride-hailing giants Uber Technologies Inc. and Lyft Inc. But Uber immediately signaled defiance, saying it didn’t plan to change its practices in response to the measure.

The legislation, which intends to force companies to reclassify certain contract workers as employees, is considered a serious threat to Uber and Lyft, already losing billions of dollars a year combined, as their business models have relied on flexible labor and minimal worker costs.

The bill’s passage in the state Assembly on Wednesday, after the state Senate’s passage the night before, reflects the degree to which the large Democratic majority in Sacramento has increased scrutiny of tech companies in recent years, as well as the strength of labor unions in the state.

Given California’s size and history of creating influential business regulations, it also is the first significant step in a new paradigm for a changing workforce, fueled by people who have forgone benefits for the sake of flexibility and occasional incentives.

Gov. Gavin Newsom, a Democrat, has said he would sign a bill if it gets to his desk.