A California judge has ruled unconstitutional a 2020 referendum passed by the state's voters that lets "gig workers" be treated as contractors, in a decision revealed Friday.

Labor legislation is known as Proposition 22 -- heavily backed by Uber, Lyft, and other app-based, on-demand services -- effectively overturned a California law requiring them to reclassify their drivers and provide employee benefits.

Uber attacked the decision and pledged to challenge it.

"This ruling ignores the will of the overwhelming majority of California voters and defies both logic and the law," the ride-hailing service said in a statement.

"Meanwhile, Prop. 22 remains in effect, including all of the protections and benefits it provides independent workers across the state," it added.

The November vote came after a contentious campaign with labor groups claiming the initiative would erode worker rights and benefits, and with backers arguing for a new, flexible economic model.

The victory for the "gig economy" in California was expected to echo across the US, is a boon for app-based services while igniting fears that big business is rewriting labor laws.

Under the proposition, drivers remained independent contractors but Uber and Lyft were to pay them a number of benefits including a minimum wage, a contribution to health care, and other forms of insurance.

Critics of the measure said it failed to take into account the full costs borne by drivers.

Uber and Lyft claimed most drivers support the contractor model.

But the firms had been sued by the state, which argued keeping that model violated California labor law. A Proposition 22 victory rendered the court case effectively moot.