New York City’s law to limit the amount of time Uber and Lyft drivers can spend cruising for passengers in busy parts of the city is “arbitrary and capricious,” a New York State Supreme Court judge ruled Monday.

Last summer, the city’s Taxi and Limousine passed rules requiring drivers reduce so-called deadheading — or the amount of time spent without passengers in the car — from 41 percent to 31 percent in Manhattan below 96th Street. The city said it was trying to reduce traffic congestion, which has risen in the years since ride-hailing took off. Uber sued to overturn the law, arguing it threatened driver pay and flexibility.

In his ruling, Judge Lyle E. Frank took issue with the city’s definition of “cruising.” He said there was “no rational basis” to calculate the time drivers spend looking for new passengers as part of the definition. And there was “scant rationale” for the city’s choice of 31 percent as the target for deadheading. Frank annulled the rule, which would have gone into effect starting in February.

“no rational basis”

The ruling was the latest volley in the long-running battle between New York and app-based ride-hailing companies. The city has twice extended its cap on the number of Uber and Lyft vehicles permitted to operate within the city. A moratorium on new vehicle licenses now extends until August 2020. NYC Mayor Bill de Blasio has said that he wants the prevent Uber and Lyft from “taking advantage of hardworking drivers, choking our streets with congestion, and driving workers into poverty.”

Uber and Lyft have been limiting drivers’ access to the app in response to the anti-cruising rule. The company is locking drivers out during certain times of the day and in areas of low demand. Uber has accused the city of harming driver earnings and slashing service in low-income communities that are underserved by public transportation.

“We are pleased that the Court recognized that Mayor de Blasio’s cruising cap is arbitrary,” an Uber spokesperson said in an email. “Uber remains committed to fighting for driver flexibility in the face of politically-motivated regulations and to stand up for policies that actually combat congestion.”

The city is reviewing its legal options, including a possible appeal.

“These corporations have flooded our streets with so many cars that more than 40% drive around empty and clog our streets,” a de Blasio spokesperson said in an email. “These 85,000 new vehicles create significant environmental problems, as well as make it a headache for New Yorkers to get around the City in a timely fashion. We put these rules in place to protect hardworking drivers and New Yorkers—and we’ll fight to keep them.”