The city won a legal victory Wednesday against three lawsuits that said it was illegal for Uber and other app companies to operate in New York City, handing the decimated yellow cab industry another blow.

The decision is a win for both the city and Uber -- even as Mayor Bill de Blasio's administration battled the app company over traffic congestion this summer and tried to cap the number of its cars on the streets.

The largest lender to taxi medallion owners, Melrose Credit Union, sued the city in Queens Supreme Court with other credit unions. They had made almost $2.5 billion in loans for 5,331 city-issued medallions going back to 2006.

The lenders argued that apps like Uber, which uses black cars, were violating the yellow cabs' exclusive right to pick up street hails in New York state law -- and that their "illegal" operations had caused the value of medallions to drop up to 40%.

The city has argued that rides using electronic apps like Uber are prearranged trips, not hails.

Judge Allan Weiss said in his rulings that the TLC has the authority to decide that electronic communications between Uber and passengers are prearranged trips -- and that the distinction has softened because of the apps.

"Uber-type companies are a new form of black car companies, and the TLC, having the authority to promote technological innovation and new services may, where necessary, treat the new companies somewhat different from the traditional companies," said Weiss in the court papers.

"Uber-type companies may not fit neatly into the traditional black car regulatory and the TLC must be allowed a reasonable amount of administrative discretion in applying rules as new circumstances arise."

Weiss dismissed all three related suits. They included one by two luxury car services, as well as one involving the Committee for Taxi Safety, which represents driver-owned medallions.

Todd Higgins, the attorney for Melrose Credit Union and the other plaintiffs, said they would immediately appeal the ruling.

"We respectfully disagree with today's decision by the Supreme Court upholding, as a matter of 'administrative' discretion, the TLC's blatantly arbitrary and caprious determination, in direct violation of New York State law," Higgins said. "That an E-Hail constitutes a form of prearrangement, rather than a 'hail'."

The Taxi and Limousine Commission said it was good news for riders.

"This decision is a victory for the riding public, and leaves no question as to the appropriateness of our regulatory approach to app-dispatched services," said TLC Commissioner Meera Joshi. "Passengers will remain free to continue to enjoy the many transportation options available to them, whether new, more traditional, or both."

Uber also praised the ruling.

"We are pleased with the decision, and appreciate the administration and TLC's work on this," said Josh Mohrer, a general manager for Uber in New York City.

Higgins also spoke Wednesdayabout the decimated taxi industry, which has seen a significant drop in yellow cab trips.

"A catastrophe is unfolding, as an entire industry continues to be illegally destroyed, while elected officials allow it to happen on their watch," he said.