Yet some members of the ultra-Orthodox community accused Mr. de Blasio of having overstepped his authority by issuing the vaccination declaration, and a lawsuit filed Monday argues that the city’s order was unjustified because of “insufficient evidence of a measles outbreak or dangerous epidemic.”

City officials said they had noticed an increase in infections after the Jewish holiday of Purim last month, and became worried that there could be another spike with the upcoming Passover holiday. The mayor said public health, not his relationship with the Orthodox community, was his priority.

“I can say that we try always to respect religious rights, religious customs, but when it comes to public health, we see a problem emerge, we have to deal with it aggressively,” he said.

[90 New Cases of Measles Reported as Outbreak Continues at Record Pace]

Brad Lander, a councilman from Brooklyn who holds Mr. de Blasio’s former seat, disagreed with the mayor; he said he thought the city seemed slow to respond to the crisis.

But he added that the mayor’s relationship with the ultra-Orthodox community might have actually helped ease potential tension, especially when compared to past flare-ups.