Uber and Postmates have mounted a legal challenge seeking to block AB5, California’s landmark gig-work law scheduled to take effect on Jan. 1, that could turn the companies’ drivers and couriers into employees rather than independent contractors.

AB5 is “irrational and unconstitutional,” contends a lawsuit, Olson vs. California, filed Monday in U.S. District Court in Los Angeles. The plaintiffs — Uber, Postmates, an Uber driver and a Postmates courier — say they seek to defend the “fundamental liberty to pursue their chosen work as independent service providers and technology companies in the on-demand economy.” AB5 violates due process by infringing on this right, the lawsuit says.

The suit claims that AB5 targets “modern app-based” ride and delivery companies, even while exempting dozens of other professions, thus violating equal protections.

“There is no rhyme or reason to these nonsensical exemptions,” it says. The law also violates the constitutionally protected contracts clause, the suit says, as it would “impermissibly upend hundreds of thousands of valid, existing contracts between on-demand workers” and companies.

The lawsuit is the latest salvo by gig-economy companies that say AB5 could devastate them by removing the flexibility that their business models depend on. AB5 supporters say that gig companies that hire workers as independent contractors are denying them the protections and benefits of

employee status, as well as pinching pennies on labor costs.

“The one clear thing we know about Uber is they will do anything to try to exempt themselves from state regulations that make us all safer and their driver employees self-sufficient,” AB5’s author, Assemblywoman Lorena Gonzalez, D-San Diego, said in a statement, calling the lawsuit’s claims bizarre.

The lawsuit directly targets Gonzalez, accusing her of bias and “overt hostility to on-demand work” that led to the passage of AB5. It notes that she tweeted in November to the city attorneys of the state’s four largest cities asking them to mount court battles to enforce AB5 on Jan. 1 — a power that the new law itself grants them.

AB5 was based on a 2018 California Supreme Court decision called Dynamex that established a stricter test for when companies can claim workers are independent contractors. It seeks to codify and clarify Dynamex, which is already the law of the state, as well as to expand its reach to unemployment benefits and other labor protections.

Uber, Lyft, DoorDash, Postmates and Instacart have pledged $110 million for an initiative that they hope to place on the November 2020 ballot. The proposed measure would keep their drivers and couriers as independent contractors while allowing them to receive some benefits and wage guarantees.

Other industries and workers are also pushing back against AB5. Truck drivers and freelance writers and photographers have mounted their own lawsuits over the new law.

The 49-page lawsuit seeks a court declaration that AB5 is invalid and unenforceable against the plaintiffs, as well as an injunction stopping California from enforcing the new law against Uber and Postmates.

The two driver plaintiffs each wrote opinion pieces about their motivations for joining the case.

AB5 “has thrown my life and the lives of more than a hundred thousand drivers into uncertainty,” Lydia Olson, an Uber driver from Sacramento, wrote in a Medium post. “This independent contractor arrangement gives me the peace of mind that I can do what is necessary to take care of my family on my own schedule.”

The office of California Attorney General Xavier Becerra, who would defend the state against the lawsuit, said it will review the complaint.

Carolyn Said is a San Francisco Chronicle staff writer. Email: csaid@sfchronicle.com Twitter: @csaid