“The threat remains, given other outbreaks in the U.S. and around the world,” said Dr. Oxiris Barbot , the city’s health commissioner. “Our best defense against renewed transmission is having a well-immunized city.”

With the passage of the new law on June 13, New York became only the fifth state to bar all nonmedical exemptions to vaccination and now has among the strictest policies in the nation .

Maine, where a new law barring all but medical exemptions does not go into effect until 2021, makes exceptions for special education students. California, where nonmedical exemptions were ended in 2015, gave parents with nonmedical exemptions extra time to comply, and allowed districts to exempt disabled children.

The New York law allows no such exceptions.

The anti-vaccination community in New York has filed several lawsuits seeking to block the legislation, but none have succeeded so far.

At the same time, state health officials have been moving to close additional loopholes, announcing in August emergency regulations that make medical exemptions to vaccination harder to get. (In California, officials said, the medical exemption rate to vaccination increased from 0.2 percent to nearly 1 percent after other exemptions were eliminated, dulling the law’s intended impact.)

“I assure you, vaccines are safe and effective,” Dr. Howard A. Zucker, the state health commissioner, says in a public service announcement running on television. “I’m a father,” he adds. “My kids are vaccinated.”

The law is already encouraging parents on the fence about vaccination to immunize their children, and is sending a message to public and private schools that the days of selective vaccination are over. But for parents who remain deeply skeptical, more steps will be needed, according to doctors who study vaccine refusal.