A bill that could upend the business models of Uber, Lyft and other companies that rely on independent contract workers is on its way to a vote on the California Senate floor after passing a key committee, setting the stage for an expensive war between tech companies and labor unions.

AB 5 would codify a ruling by the state Supreme Court last year, which applies a new, simpler test for when a worker should be considered an employee. It could require the ride-hailing giants to provide drivers with higher pay, benefits and legal protections.

The bill passed the Senate Appropriations Committee 5-2 Friday. The state Senate must vote on it before the last day of the legislative session Sept. 13, and Gov. Gavin Newsom must sign it within a month.

AB 5 has been under assault from Uber and Lyft, which are urging drivers and riders to contact their lawmakers to oppose it because they say it would lead to a drastically reduced driver base — Lyft released a study this week saying 300,000 of its drivers in California could find themselves out of work — and mean higher prices for riders who use their services.

The companies are proposing a minimum wage of $21 an hour for drivers and access to benefits, but do not want them classified as employees. They are also pushing for sectoral bargaining for the ride-hailing industry, saying drivers would get a say in setting their working conditions — and that the unions are advocating for the same thing.

The San Francisco-based ride-hailing giants also announced this week that if they don’t get what they want, they plan to take the issue to California voters. The two companies are depositing $30 million each into an account for a 2020 ballot initiative, and they were joined by delivery service DoorDash, which also said it would put up $30 million.

“We are working on a solution that provides drivers with strong protections that include an earnings guarantee, a system of worker-directed portable benefits, and first-of-its kind industry-wide sectoral bargaining, without jeopardizing the flexibility drivers tell us they value so much,” said Adrian Durbin, Lyft’s director of policy communications, in a statement. “We remain focused on reaching a deal, and are confident about bringing this issue to the voters if necessary.”

Uber said it remains hopeful that it can reach a compromise with lawmakers.

The author of AB 5, State Assemblywoman Lorena Gonzalez, D-San Diego, said Friday on Twitter: “It’s time to show working people and taxpayers that we are with them, not Wall Street billionaires.”

Uber and Lyft drivers are pushing hard for AB 5. This week, dozens of them drove to Sacramento to rally in front of the  Capitol, with signs reading “Unions for all” and “Stop the exploitation.” They also protested in front of Uber headquarters in San Francisco.

Some drivers say the minimum wage of $21 the companies are proposing is not adequate, because they wouldn’t get paid while in between rides.

“Everything about their proposal is far from even being remotely enough,” said Edan Alva, who has been driving for Lyft in the Bay Area for nearly five years, on Friday after the bill advanced in the legislature. “Drivers deserve the right to organize … to actually have a legitimate full-fledged union.”

In addition, labor unions are vowing to fight the gig-economy companies.

“This is landmark legislation that could be life-changing for workers,” said Steve Smith, spokesman for California Labor Federation, on Friday. “We’re fully prepared to run a vigorous worker-led campaign to beat back any attempt by gig corporations to skirt the law by spending tens of millions of dollars at the ballot.” He noted that six presidential candidates — including Sens. Bernie Sanders and Elizabeth Warren — support AB 5.

“This is a classic battle between two powerful interests,” Larry Gerston, professor emeritus for San Jose State University’s political science department, said Friday. He pointed out that the gig-economy companies are on the same side as “well-established industries such as truckers, various franchise owners and companies that depend on a labor force of independent contractors,” — some industries have sought and received exemptions under AB 5 — while gig-economy workers and labor unions are on the other side.

Gerston estimated that a fight between the two sides could reach up to a couple of hundred million dollars.

Ultimately, what it all means is “higher fares for the public no matter what happens,” William Gould IV, emeritus professor of law at Stanford Law School and a former chief of the National Labor Relations Board, said Friday.