New York officially ended religious exemptions for school vaccines Thursday as the state grapples with its largest measles outbreak in years.

Gov. Andrew M. Cuomo (D) signed the legislation into law Thursday evening after it passed in the state’s Senate and Assembly, ending years of gridlock over the issue.

“We’re putting science ahead of misinformation about vaccines and standing up for the rights of immunocompromised children and adults, pregnant women and infants who can’t be vaccinated through no fault of their own,” state Sen. Brad Hoylman (D) said in a statement.

The law gives unvaccinated students up to 30 days to show they’ve started their required immunizations.

All states have laws requiring various vaccines for students and all allow for medical exemptions. Many also grant parents the right to exempt their children from the vaccines for religious reasons, and a smaller number for philosophical reasons.

But the tide of public opinion has been changing as measles cases this year have already surged to the highest levels since 1992.

More than 1,000 cases of measles in at least 13 outbreaks have been diagnosed in the country this year, with the majority in New York.

The cases have largely stemmed from the ultra-Orthodox Jewish population in Brooklyn, and to a lesser extent, Rockland County, which anti-vaccine groups have had some success at targeting with misinformation. Many of these activists claim that vaccines cause autism, a link disproved repeatedly by scientists and medical experts.

Measles, a highly contagious and potentially life-threatening disease, was thought to have been eliminated in 2000, due to the success of decades-long campaigns to get people vaccinated.

Of New York’s measles cases, 74 percent have come from the Williamsburg neighborhood in Brooklyn, home to a large ultra-Orthodox population.

Opponents of the bill protested Thursday outside of New York’s capitol in Albany before the vote, claiming the legislation is an assault on religious freedom. Inside the building, some people chanted, “Shame,” after the measure passed the Assembly, while another woman shouted obscenities at lawmakers, the Associated Press reported.

“I’m not aware of anything in the Torah, the Bible, the Koran or anything else that suggests you should not get vaccinated,” Bronx Assemblyman Jeffrey Dinowitz (D), the bill’s sponsor, told reporters. “If you choose to not vaccinate your child, therefore potentially endangering other children … then you’re the one choosing not to send your children to school.”

New York joins states such as California, Mississippi, West Virginia and Maine by outlawing nonmedical exemptions for vaccines. Several other states are deliberating whether to eliminate religious waivers for vaccines.

“The science is crystal clear: Vaccines are safe, effective and the best way to keep our children safe,” Cuomo said in a statement. “While I understand and respect freedom of religion, our first job is to protect the public health and by signing this measure into law, we will help prevent further transmissions and stop this outbreak right in its tracks.”

The bill’s passage was coupled with the news that the New York City Health Department has closed two private schools in Williamsburg for failing to comply with a recent emergency health order. The Health Department said the two schools failed to provide proof of immunity for a student at the school and allowed other unvaccinated children and staff on site. The Health Department has closed 11 schools over vaccine-related issues this year.

Lena Sun contributed to this report.

Read more: