(CNN) Amid an ongoing measles outbreak, New York is requiring schoolchildren to be vaccinated, even if parents have religious objections.

Gov. Andrew Cuomo signed legislation Thursday that removes nonmedical exemptions from school vaccination requirements. The law goes into effect immediately, his office said.

The move, which comes despite opposition from anti-vaccination activists and religious freedom advocates, puts New York alongside other states that do not allow nonmedical exemptions : California, Mississippi, West Virginia and Maine.

"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 Thursday.

"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," he said.

"We are dealing with a public health emergency that requires immediate action," state Sen. Brad Hoylman, sponsor of the Senate bill, said during the vote.

New York has become the epicenter of a measles outbreak in the United States that is now in its ninth month. More than 800 people in New York have become sick, and New Yorkers have infected people in four other states.

This year, 1,022 measles cases have been confirmed in 28 states, marking the greatest number of cases reported in the country since 1992 and since the measles virus was declared eliminated in the country in 2000, according to the US Centers for Disease Control and Prevention.

The states that have reported cases to the CDC are Arizona, California, Colorado, Connecticut, Florida, Georgia, Idaho, Illinois, Indiana, Iowa, Kentucky, Maine, Maryland, Massachusetts, Michigan, Missouri, New Mexico, Nevada, New Hampshire, New Jersey, New York, Oklahoma, Oregon, Pennsylvania, Texas, Tennessee, Virginia, and Washington.

Regarding the new legislation, "this is a great step forward in protecting the public health here in New York," Ed Day, Rockland County executive, said in a written statement. His county is among those with the highest number of measles cases in the state.

"This law should lead to a substantial increase in vaccination rates and to improved protection of our most vulnerable residents; infants, the immunocompromised and those who have legitimate medical issues. With Rockland being an epicenter of the current measles outbreak, we greatly appreciate that our advocacy and local efforts were heard and acknowledged," he said.

Most of the cases in New York have been in Orthodox Jewish communities In Brooklyn and Queens with low vaccination rates.

Health authorities in New York say they've faced formidable challenges to quell the outbreak: anti-vaxers who specifically targeted the state's ultra-Orthodox Jewish community, bombarding them with lies that vaccines cause autism.

"We are now countering not only the vector of the measles virus, but we're countering the vector of the anti-vaxers, and that message -- that insidious message -- is just as challenging as the most contagious virus on the face of the earth," said Dr. Oxiris Barbot, commissioner of the New York City Department of Health and Mental Hygiene.

Get CNN Health's weekly newsletter Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

New York health authorities face an additional challenge: ultra-Orthodox Jews travel frequently to Israel and Europe, where there have been more than 100,000 measles cases this year.

When asked whether she thought the outbreak would end by the fall in order to keep the country's measles elimination status intact, Barbot didn't answer.

"We are working every day, day and night, to ensure that we get the message out that vaccines are safe, effective, and the best way to keep families and communities safe," she said.