A state judge on Thursday rejected a lawsuit filed by anti-vaccination parents who sought to lift New York City’s new measles vaccination mandate, as parts of the metropolis continue to face an outbreak.

“A fireman need not obtain the informed consent of the owner before extinguishing a house fire,” Judge Lawrence Knipel wrote in his ruling. “Vaccination is known to extinguish the fire of contagion.”

Five anonymous parents in Brooklyn filed the lawsuit earlier this week against the city health department for ordering the mandatory vaccinations in parts of the borough amid a growing outbreak of the measles virus concentrated in the Williamsburg area. The lawsuit said the city’s response is “irrational,” and that the spread of the virus does not pose a clear danger to public health.

Knipel ruled that the city’s decision to require measles vaccinations during the outbreak is supported by “largely uncontroverted” evidence.

New York City Health Commissioner Oxiris Barbot issued the emergency order on April 9, requiring everyone who lives and works within four Brooklyn ZIP codes to receive the measles, mumps and rubella (MMR) vaccine if they hadn’t already gotten it. Failure to comply with the mandate could result in misdemeanor punishments, including criminal fines or imprisonment.

The city has already issued summons to three people who refused the mandate and face $1,000 in fines.

As of Wednesday, the measles outbreak has infected at least 329 people since October, mostly children from Orthodox Jewish communities in Brooklyn, according to Barbot. Some in these communities have resisted vaccination, in Brooklyn as well as in Upstate New York, where The Forward reports vaccination rates at some schools around 60%. Groups like the Orthodox Union and other religious leaders, meanwhile, have declared that there is no religious obstacle to getting vaccinated.

Barbot praised the decision to dismiss the lawsuit, saying in a statement to HuffPost that it “will protect New Yorkers from a very dangerous infection with potentially fatal consequences.”

She added that officials “do not want to issue violations but will continue and hope that New Yorkers make the best choice for their families, their neighbors and their own health ― to get vaccinated.”