The New Jersey Legislature was on the verge of passing one of the strictest pro-vaccine laws in the nation on Monday, which would end religious exemptions to vaccine requirements for students enrolled in any day care, school or college, public or private.

The hotly contested bill, which comes on the heels of a measles outbreak in the region this year, has been framed as a crucial public health measure by its supporters, and as a dangerous infringement on religious and personal rights by its opponents.

As the State Assembly passed its version of the bill — 45 to 25, with six abstentions — dozens of families in the gallery who oppose the legislation began chanting: “We will not comply.”

The bill now heads to the Senate for a vote later on Monday, and then if it passes would go to Gov. Philip D. Murphy, who would sign or veto it. The governor is a Democrat and both houses of the Legislature are controlled by the party.

“The constitution tasks us with promoting the general welfare and therefore, we cannot let unsubstantiated fears endanger the public, and especially not our classrooms,” Senator Loretta Weinberg, a Democrat from Teaneck who co-sponsored the Senate bill, said in a statement.

“There is no exemption for drunken driving or wearing a seatbelt, so there should not be an exemption from a patently safe vaccine that, if not taken, puts the health and well being of our children at risk.”

In recent years, the rate of religious exemptions in New Jersey’s schools have been rising. In June, New York passed a similar law to end religious exemptions, but New Jersey is going further by also ending exemptions at institutions of higher education.

If the bill passes, New Jersey will join five other states that only allow medical exemptions.

“States have a compelling interest in preventing disease and death,” New Jersey Assemblyman Herb Conaway, who is a practicing physician and chairman of the Assembly Health Committee, said as he introduced the bill on Monday.

The bill in New Jersey has been strongly opposed by thousands of anti-vaccine families from a wide variety of religious backgrounds, who have flooded the statehouse in recent days to express their objections.

They have won the support of many lawmakers, including the Republican Assembly minority leader, Jon Bramnick of Union County. In floor debate before the bill’s passage, Mr. Bramnick called the bill overly broad.

“To tell a doctor that they cannot use their ability, their expertise, to write an exemption handcuffs doctors,” he said, referring to language in the bill that also tightens the rules for granting medical exemptions.

Among those opposing the bill is the nation’s main ultra-Orthodox Jewish umbrella organization, Agudath Israel of America, which is taking a more active role in fighting the measure in New Jersey than it did in New York.

New Jersey is home to the largest Orthodox yeshiva in the country, Beth Medrash Govoha, which is in Lakewood and has about 7,000 students.

While most Orthodox Jews vaccinate their children, many rabbinical authorities “are very concerned about this bill” because it mandates vaccines even in those cases where a rabbi may decide they are unwarranted, said Avi Schnall, the New Jersey director of Agudath Israel of America.

Such a situation, he said, might arise in cases in which a family believes it has two children injured by vaccines, and is debating whether to vaccinate a third child. Most rabbis would rule that such a child should not be vaccinated, he said.

“There is a religious element to vaccines,” he said. “And for the state to eliminate the religious exemption, it sets a precedent, it begins a slippery slope. And it’s not a good place for the state to be telling people, ‘Well, we don’t consider this to be religious, so we are taking it away.’”

Most states do allow families to claim religious exemptions to mandated vaccinations, but that is changing. If the law is signed, New Jersey would join New York, California, Maine, Mississippi and West Virginia as states requiring that all children enrolled in school be vaccinated unless they have a valid medical reason.

In New Jersey, some 94.2 percent of grade school students — more than 500,000 in all — were vaccinated in the 2018-19 school year, according to state records, a rate which meets the “herd immunity” threshold that many infectious disease authorities say is required to protect the population at large.

But that percentage represents a drop from the 95.3 percent in 2013-2014, in large part because of the rise in religious exemptions, which have grown to 2.6 percent from 1.7 percent over that period.

That trend has worried policymakers, because unvaccinated children tend to exist in clusters, enabling infectious diseases to take hold in those communities and posing a threat to those who cannot vaccinate for medical reasons, such as weak immune systems.

“This is about keeping our children healthy and our classrooms safe,” said Senator Joseph Vitale, a Democrat. “We require vaccinations to protect those who, medically, cannot be vaccinated.”

The bill would take effect 180 days after being signed by Mr. Murphy.