James Martin/CNET

Ride-hailing companies Uber and Lyft have been dealt a setback in their efforts to prevent their drivers in Seattle from unionizing.

US District Court Judge Robert Lasnik for the Western District of Washington state on Tuesday dismissed a lawsuit filed by the US Chamber of Commerce in March to block a Seattle ordinance that would allow drivers for ride-hailing companies to unionize. The Chamber, which counts Uber and Lyft as members, argued the ordinance violates antitrust laws by allowing independent contractors to collude through collective bargaining to fix prices.

Lasnik said in his ruling that the ordinance is an appropriate exercise of the city's authority. However, a temporary order issued by Lasnik in April blocking the ordinance will remain intact.

The fight over Seattle's ordinance is part of a bigger fight over what level of benefits are owed to independent contractors in the "gig economy." Critics charge that Uber and Lyft reap a financial windfall by treating its drivers as contractors and thus avoiding higher costs such as paying benefits, overtime and insurance. If drivers unionize, they would have leverage in negotiating pay and perks.

Uber criticized the ruling, saying it would appeal the decision to the 9th US Circuit Court of Appeals.

"The court's decision ignores the serious legal challenges raised in this case about an ordinance that will turn back the clock in Seattle," Brooke Steger, Uber general manager for the Pacific Northwest, said in a statement. "If this ruling is allowed to stand, those most adversely affected will unfortunately be thousands of drivers."

Lyft echoed that disappointment. "Seattle's poorly drafted ridesharing ordinance could undermine the flexibility of drivers to choose when, where and for how long they drive," Lyft spokesman Adrian Durbin said in a statement.

Seattle became the first US city to give Uber and Lyft drivers the right to form unions in 2015 when it passed an ordinance stating that drivers of on-demand ride-hailing companies can create unions to bargain on issues of pay and working conditions.

Does the Mac still matter? Apple execs tell why the MacBook Pro was over four years in the making, and why we should care.

Tech Enabled: CNET chronicles tech's role in providing new kinds of accessibility.