A judge ruled on Thursday that the New York City health department could not require young children to be vaccinated for the flu to attend city-licensed preschools and day care centers, striking down one of the more ambitious public health initiatives of the Bloomberg administration.

Justice Manuel J. Mendez of State Supreme Court in Manhattan said the city could not add influenza to the list of diseases requiring immunization without action by the State Legislature.

Dr. Mary T. Bassett, the city’s health commissioner, said the decision would put thousands of children at unnecessary risk.

“I am extremely disappointed by today’s decision,” Dr. Bassett said in a statement. “Influenza kills an average of 24,000 people each year in the United States, and the virus is spread easily in child care settings to children and their families. The vaccination requirement will save lives.”