New York Gov. Andrew Cuomo (D) signed legislation Thursday to end religious exemptions for vaccines.

The legislation comes as the U.S. grapples with one of its worst outbreaks of measles in years.

Cuomo signed the bill almost immediately after the New York state Senate and Assembly advanced the measure.

"The science is crystal clear: Vaccines are safe, effective and the best way to keep our children safe. This administration has taken aggressive action to contain the measles outbreak, but given its scale, additional steps are needed to end this public health crisis," Cuomo said in a statement. ADVERTISEMENT

"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 governor's office argued that this measure would help protect the public amid an ongoing measles outbreak.

Hundreds of people, including parents who have refused to vaccinate their children, turned out to the New York Capitol to protest the legislation on Thursday, The Associated Press reported. The opponents reportedly argued that the measure focused on nonmedical exemptions was an assault on religious freedom.

The law’s passage in New York comes after Maine lawmakers voted to eliminate religious exemptions for vaccines. But AP noted that similar exemptions still exist in 46 states.

There have been 1,022 cases of measles in 28 states since January, according to a report from the Centers for Disease Control and Prevention this week. The numbers represent America's worst measles outbreak in more than 25 years.

New York City has reported 588 cases of measles since last September. The New York Department of Health has said that there are 336 confirmed cases elsewhere in the state.

Many of the cases have involved members of the Orthodox Jewish community, many of whom have invoked religious exemptions to stop a child from receiving a measles vaccine.

“Vaccines save lives. We are in the midst of a measles epidemic which is completely preventable given proper immunizations,” state Senate Majority Leader Andrea Stewart-Cousins (D) said in a statement earlier Thursday.

Students in every U.S. state are mandated to receive a vaccination in order to attend school. But various exemptions exist for students who may be too ill to receive a vaccine. The New York legislation does not focus on medical exemptions.

UPDATED 7:07 p.m.