MADRID -- The Spanish government on Thursday announced legislation that classifies food delivery riders as employees of the digital platforms they work for, not self-employed, in a legal change that could have far-reaching consequences for Spanish businesses.

The legislation also includes a groundbreaking requirement for companies operating the platforms, such as Glovo and Deliveroo, to hand over to their workers' legal representatives information about how their algorithms and artificial intelligence systems function in assigning jobs and assessing performance, among other aspects.

The Minister for Labor, Yolanda Diaz, said the new law is "pioneering" and is part of "a modernization of the labour market" in Spain, updating regulations in accordance with technological developments to ensure workers' rights are upheld.

She described the rule on disclosing how the digital systems work as "epic," saying it "neutralizes algorithmic punishments."

The legal changes are the latest affecting companies and workers in the gig economy. Last month, Britain's top court ruled that Uber drivers should be classed as "workers" and not self-employed, in what was seen as a major setback for the ride-hailing giant.

The Spanish government agreed on the new law with the country's main business groups and trade union confederations.

But the law, which is expected to come into force within months, was quickly contested by an association of digital platforms providing food delivery services and by some riders who prefer the flexibility of being self-employed.

The Association of Service Platforms said that the rule on disclosing algorithms is "a measure which undoubtedly will have a very negative effect on the development of the digital economy in Spain."

The rule is "an assault on the most basic principles of the freedom to do business and intellectual property rights," the association said in a statement.

The legislation was drawn up after Spain's Supreme Court ruled last September that food delivery riders are employees, not self-employed workers, in a case brought by a former rider for Glovo.

London-based Deliveroo urged the Spanish government to think again, warning in a statement that the measures "will lead to less work for riders, will hurt the restaurant sector and will restrict the areas where platforms can operate."

Uber, which operates the Uber Eats service, said it is "fully committed to raising the standard of work and giving independent workers more benefits while preserving flexibility and control." An Uber statement noted that thousands of couriers had recently protested across Spain to demand they be allowed to remain independent.