ALBANY — A court hearing drew more than 1,000 people to Albany on Wednesday who were there to protest a new law ending religious exemptions to New York school vaccination requirements.

The hearing was a chance for acting Albany County Supreme Court Justice Denise Hartman to hear arguments from attorneys about why she should or shouldn't grant a preliminary injunction blocking the law ahead of the upcoming school year.

But it quickly took on the feel of a campaign-style event, as parents and children dressed in white packed the courtroom, hallways and court steps to hear from and cheer on attorneys Michael Sussman and Robert F. Kennedy, Jr., an environmental attorney whose name has become synonymous with the anti-vaccine movement.

"You are defending one of the foundational, cornerstone rights of the American republic," Kennedy told the crowd in a rally after the hearing.

Sussman and Kennedy sued the state last month over the law, arguing it was motivated by religious animus and violates parents' constitutionally protected right to religious freedom. In court Wednesday, assistant state Attorney General Helena Lynch disputed those claims.

"The right to free expression of religion does not encompass the right to endanger the lives, health and safety of others," she said. "And the Supreme Court has held that."

All 50 states including New York allow medical exemptions to school immunization requirements, and many also offer exemptions for religious, philosophical or personal reasons. But a number have moved to eliminate all non-medical exemptions as the nation grapples with its worst measles outbreak since 1994.

In response to the outbreak, which was largely fueled by cases in New York, lawmakers voted June 13 to repeal the state's religious exemption, which was its only non-medical exemption to school vaccine rules.

Sussman and Kennedy argue that repeal was unconstitutional because it was motivated by "active hostility" toward religion. This was evident, they said, when certain lawmakers called religious exemptions "utter garbage," "a myth and fabrication" and "a loophole."

Lynch said lawmakers were motivated only out of concern for public health, and contends those remarks represented skepticism about religious exemptions, not hostility.

"One of the legislators stated that 90-plus percent of the calls he received were from people expressing personal objections, not religious objections," she said. "So there is a basis for skepticism on the part of legislators."

Plaintiffs' attorneys also sought to overturn the repeal on the grounds that it would cause irreparable harm to more than 26,000 families who would have to choose between violating their religious beliefs in order for their children to attend school or pulling them out and homeschooling them.

The law applies to public, private and parochial schools.

Hartman made no decisions Wednesday, and indicated she hoped to make a determination on the preliminary injunction before the start of school, or within the 14-day window after school starts that children must be vaccinated.