Uber Technologies Inc. and Postmates Inc. sued the state of California, alleging that a labor rights law set to go into effect this week is unconstitutional.

The lawsuit filed Monday in Los Angeles federal court is a preemptive strike against the state’s landmark measure designed to ensure gig workers receive employment protections. Uber and Postmates argue the legislative process around California’s Assembly Bill 5 unfairly targeted gig economy companies while favoring other industries and that the law will threaten workers’ flexibility.

Dara Khosrowshahi, Uber CEO
Dara Khosrowshahi, Uber CEO

The passage of A.B. 5, which takes effect Wednesday, has set in motion a bitter dispute about the rights of Uber drivers, food couriers and other people who derive their income from apps made in Silicon Valley working as independent contractors.

Uber and Postmates say it’s arbitrary that direct salespeople, travel agents, grant writers, construction truck drivers, commercial fishermen and others are exempted from the law.

“There is no rhyme or reason to these nonsensical exemptions, and some are so ill-defined or entirely undefined that it is impossible to discern what they include or exclude,” according to the complaint.

The impact of A.B. 5—and the backlash against it—extends beyond the technology industry. Two organizations representing freelance journalists brought a legal challenge this month, saying the law restricts free speech and the news media by effectively limiting the number of articles a contract journalist can write for the same publication each year. The trucking industry, in its own lawsuit, says the measure would make it “impractical if not impossible” to use independent contractors for services across state lines.

But tech companies have far more at stake financially if they are forced to provide overtime pay, health care and other benefits to the armies of contract laborers they rely on to drive customers around and deliver food. With their business models threatened, DoorDash Inc., Lyft Inc. and Uber have said they’ll spend a combined $90 million on a campaign asking California voters to overturn the law in the next election. Lyft and Uber have each committed to turning a profit by the end of 2021, a promise that could be unattainable if they’re forced to reclassify workers in their home state.

The labor issue looms as a risk for Postmates as it heads toward a planned initial public offering. The food delivery company agreed to pay about $11.5 million to settle misclassification claims brought by couriers in California. Last month, a judge expressed “significant concerns” with the deal and sought more information.

In Monday’s complaint, Uber, Postmates and one driver from each company who are also plaintiffs said they want a judge to block A.B. 5 from being implemented. They alleged that the law violates guarantees of equal protection afforded by both the U.S. Constitution and the California Constitution.

The companies take particular aim at the sponsor the sponsor of the bill, Lorena Gonzalez, who they say has spoken forcefully about targeting gig-economy firms. Gonzalez, a Democrat from San Diego, urged the city attorneys in four of the state’s biggest cities in a November tweet to go to court as soon as the law takes effect to enforce it.

Signed by California Governor Gavin Newsom in September, A.B. 5 says workers can generally only be considered contractors if they perform duties outside the usual course of a company’s business. The law adopted a more straightforward test than previously existed in California law to determine which workers qualify for employee status and the attendant benefits.Legal experts say the law weakens gig economy companies’ arguments that their drivers are independent contractors, and will make it much harder for them to continue denying California drivers benefits including business expense reimbursements that would ordinarily be available to employees.

Uber has acknowledged the higher hurdle but has said A.B. 5 is no “magic wand” that changes gig workers’ status on Jan. 1. Instead, the company has argued that the fight will need to be resolved by courts.