A state judge on Tuesday unexpectedly blocked about half of New York University’s large and hotly debated expansion plan to build four towers in the school’s leafy and largely low-scale Greenwich Village neighborhood.

The judge, Donna M. Mills, of State Supreme Court in Manhattan, ruled that the administration of Mayor Michael R. Bloomberg had wrongfully agreed to turn over three public parks to the university to enable construction without first obtaining approval from the State Legislature.

Still, the university insisted that the ruling would permit it to move forward with its largest building, a one-million-square-foot academic tower that would be erected on the site of the university’s gym. The opponents, however, argued that Justice Mills’s ruling should stop the project dead in its tracks.

While both sides claimed victory, only one thing was certain: The battle over the expansion will continue.