In a setback to efforts to defray the policing costs of large athletic events in New York City, a State Supreme Court justice in Manhattan ruled on Thursday that a nonprofit bicycling group would not have to pay nearly $1 million to close roads during its citywide tour next month.

The decision by Justice Margaret A. Chan had been largely expected after hearings on Wednesday in which she appeared unconvinced by the city’s arguments for classifying the annual event, known as the Five Boro Bike Tour, as a noncharitable athletic parade. That determination, she wrote, “is unreasonable and cannot be confirmed.”

In response, the city Law Department said it was weighing “various legal options.” The case was the first challenging the application of rules adopted in 2011 to offset the high cost of closing streets during athletic events in the city. At stake was $967,534 in fees to cover traffic control by the New York Police Department for the May 5 event.

Much of the proceeds from the event — which has an entry fee for its roughly 32,000 spots — go to the nonprofit Bike New York, which organizes the tour and provides bicycling education classes in partnership with the city.