Amid a record-setting nationwide measles outbreak driven largely by New York cases, the state ordered a Long Island school to accept unvaccinated kids into its classes and after-school activities.

The Shulamith School for Girls in Cedarhurst says the state Education Department was wrong to twice overturn the school’s decision to bar Ilana and Nikolay Jinjihashvili’s two daughters after the parents sought a religious exemption to the vaccination rule.

The Jewish day school is now asking a federal judge to overturn Education Commissioner Mary­Ellen Elia’s orders, calling them “illegal, void and unenforceable.”

While the current measles outbreak has put the vaccination debate at the forefront of public health, the school is framing the dispute as a First Amendment fight.

“There are schools that have taken the position that under the school’s religious belief, as a matter of Jewish law, students should be vaccinated,” the school’s lawyer, Philip Kalban, told The Post. The parents may have a different and “sincere” belief about vaccinations, Kalban explained, “but they say it’s based on Jewish law, and our position is that Jewish law says just the opposite.”

The First Amendment comes into play because the school argues the state has no business interfering in a religious matter.

The case landed in Brooklyn federal court last week after the family sought to send their girls to an ­after-school art show and fundraiser but were blocked by the school.

The Education Department, which had already ordered in January that the girls be permitted to attend classes, sided again with the parents and decreed that the kids be allowed to attend.

But a federal judge disagreed, noting that the “presence of an unvaccinated child at the event in question, given the current measles outbreak, would likely depress turnout among the parents and grandparents.”

The conflict comes as the number of measles cases in the United States hit 971 in just the first five months of 2019, according to the Centers for Disease Control and Prevention. That marks a 25-year high and the most since 1992, when 963 cases were recorded for the entire year.

In the city alone, 550 people were diagnosed with measles from October 2018 through May 28, along with 312 cases in the state outside of the five boroughs.

Brooklyn’s Orthodox Jewish neighborhoods have been particularly hard hit, and Mayor de Blasio recently ordered hefty fines be given to families who refuse vaccinations for their kids. Many rabbis have also come out publicly to advise worshippers to get vaccinated.

The state Health Department said it defers to the Education Department on vaccination disputes.

The family’s lawyer, Hedva Wellerstein, told The Post courts have affirmed that religious exemptions “may be based on a personal religious interpretation. My clients have rabbis that support their decisions.”

The state Legislature is currently considering a bill to eliminate religious exemptions to vaccinations. But state agencies are putting out a confusing message in this case, said Columbia and NYU public-health law professor Janlori Goldman.

“If we’re going to allow for religious exemptions then we take the risk that there’s going to be outbreaks,” she said.