Senator Richard J. Codey, a Democrat and a former New Jersey governor, said his son got calls at home. Francine Weinberg, a daughter of one of the bill’s sponsors who lives in California, said she had to adjust her Facebook page’s privacy settings to end the string of attacks from commenters.

“I call it the politics of harassment,” said Ms. Weinberg, whose mother, Senator Loretta Weinberg, was a primary sponsor of the legislation.

“And that’s really what it felt like,” Senator Weinberg added.

Among the radio personalities who opposed the bill was Bill Spadea, a Republican who supports President Trump and hosts a morning show on one of New Jersey’s largest radio stations.

“That’s what it looks like when New Jerseyans fight back against government intrusion into our families,” he wrote on Twitter, sharing a video of protesters outside the State House on Monday.

Avi Schnall, New Jersey’s director of Agudath Israel of America, a nationwide umbrella organization of ultra-Orthodox Jews, said the group had decided to publicly oppose the New Jersey legislation after regretting it had not done more to stop the measure in New York.

“We learned from our mistake,” he said in an interview last month.

Last spring, the organization had quietly opposed the New York bill, but the context had been different: The debate was taking place during an outbreak centered in the Orthodox community.

As a group, Orthodox Jews, most of whom do vaccinate their children, did not want to appear opposed to immunization. But the underlying principle of religious accommodation, the organization finally decided, was one worth fighting for, in part because there are rare cases in which a rabbi might decide a vaccination was unwarranted.