Nearly a month after the controversial measure stalled when a deluge of angry parents stormed the Statehouse in protest, state lawmakers are now poised to pass a bill that would eliminate religion as a recognized reason for children to avoid getting vaccinations required to attend New Jersey schools.

In a surprise, last-minute deal, Democratic leaders of the state Senate agreed to a series of amendments to the legislation to convince a Republican legislator to become the last vote needed for it to pass.

The changes include giving private schools and day care centers in the state the freedom to accept children who aren’t vaccinated, provided they make public a count of how many enrollees do not have their shots.

The Senate narrowly approved the amendments in an emergency vote in Trenton on Thursday. A final vote is expected to happen Monday, the last full day of New Jersey’s two-year legislative session.

Republican state Sen. Declan O’Scanlon said he agreed to provide Democrats with the deciding vote as long as the measure was made to be more flexible.

O’Scanlon, R-Monmouth, said he didn’t think it was fair that concerned families didn’t have an option, other than home-schooling their children.

“It’s not a perfect solution,” O’Scanlon told NJ Advance Media. “But it’s a justified request and a fair compromise.”

NJ Advance Media was the first to report the development Thursday, with sources confirming that O’Scanlon’s support gives Democrats the 21 votes needed for the bill (S2173) to pass the Senate and head to Gov. Phil Murphy’s desk. That’s if the vote count doesn’t drop over the weekend.

It all happened as about 1,000 people gathered outside the Statehouse to once again protest the bill for hours in the cold weather.

“Kill the bill! Kill the bill!” Hundreds of anti-vaccination demonstrators rallied outside the N.J. statehouse today. Lawmakers are deciding whether to eliminate religion as a reason for children not being vaccinated. https://t.co/gBo8UUnHIq pic.twitter.com/HOQ1rpa2Rz — NJ.com (@njdotcom) January 9, 2020

Inside, some shouted from the Senate gallery after the Senate approved the amendments, by a vote of 18-15, around 5:30 p.m.

“Murderers!" some yelled. "Traitors!” others bellowed.

The scene in the NJ senate after it took a big step towards eliminating the religious vaccine exemption at public schools pic.twitter.com/JKNXckah3p — Matt Friedman (@MattFriedmanNJ) January 9, 2020

State Senate President Stephen Sweeney told reporters he expects the bill to pass Monday when the chamber reconvenes at the Statehouse.

“It’s very fluid, but I expect to have 21,” Sweeney, D-Gloucester said after Thursday’s vote. “This is not going away. It has to be addressed. This is a public-health issue."

The state Assembly passed the bill Dec. 16, the last session before Christmas and Hanukkah. But with protesters roaring, Senate leaders called off a vote, saying they were one vote short.

Thursday, the outcry was similar, but the outcome was different.

O’Scanlon said another amendment will require schools to accept unvaccinated children if there is evidence one of their siblings has suffered a vaccine-injury and has received a settlement from the Vaccine Injury Compensation Program.

“Those children should have an automatic opt-out,” the Republican senator said.

O’Scanlon said in addition to talking with many vaccine hesitant families, he also spoke to a handful of other families whose children are immune-compromised.

“They hold their breaths sending their kids to school,” he said.

“I think we need to do all we can to maximize vaccine compliance,” the lawmaker added.

Now, the stage is set Monday for another clash with potentially thousands of parents and religious leaders who have inundated lawmakers’ offices with calls and emails for the last month.

In addition to the Senate, the Assembly would have to pass the bill again Monday because it’s been amended.

If for some reason the bill doesn’t pass both houses by noon Tuesday — the official end of the legislative session — lawmakers could take it up again in the new two-year session. Sweeney has vowed it will pass eventually.

Just like they did last month, protestors packed the courtyards outside the Statehouse on Thursday, this time chanting “O’Scanlon vote no!” and “Amendments won’t work!”

Women pounded buckets. Scores blew whistles. Bells rang and sirens howled and families shouted into megaphones, the sound so deafening that one protester used his hand to shield his toddler’s ears.

Their shouts were audible through the Senate chamber walls, drowning out lawmakers as they spoke inside.

And yes, like the last voting session, you can hearing them protests from outside loudly in the Senate chamber. pic.twitter.com/ph17cwFBwc — Brent Johnson (@johnsb01) January 9, 2020

“Start Tweeting at him now,” a woman yelled about O’Scanlon.

“What’s his Twitter handle?” asked a man with a bullhorn.

So many kids huddled in lawn chairs and under Mylar blankets that some areas looked like an underage Occupy Wall Street. When someone announced that a voting session had begun inside, the crowd broke into the Lord’s Prayer.

Beata Savreski, 40, drove down from Bergen County, her first trip to Trenton. She has three boys, and she said she doesn’t feel like the government should make this type of decision for families.

“I want to preserve our rights as parents,” Savreski said.

News that the amended bill would allow unvaccinated kids to attend private schools did not appease the masses.

“Not everyone has the funds to do that,” said Andrea Kelly, 33.

That change would only create a caste system where the rich had a choice, Kelly said. Vaccinations were a private decision between parents and their doctor, she said.

Sue Collins, co-founder of New Jersey Coalition for Vaccination Choice, said loosening the requirements on private schools is unfair to families who can’t afford to pay tuition.

“This type of amendment will once again allow the wealthy to buy their way out of a law via private schools,” Collins said. “Unless you have enough money, your religious beliefs are not valid.”

A handful of Republican lawmakers said they remained against the bill, even with amendments.

“The folks who came over on the Mayflower are all dead,” state Sen. Gerald Cardinale, R-Bergen, said on the Senate floor. “I think this has them turning over in their graves. This bill is a deliberate attack on religious freedom.”

Sen. Joseph Pennachio, R-Morris, said the measure was “tantamount to state-sponsored eugenics.”

The outbreaks of measles in New Jersey and other states convinced legislative leaders to take a closer look at the growing number of children who request a pass from vaccine laws on religious grounds. There were 13,987 New Jersey students who were granted a religious exemption in the 2018-19 academic year, according to the state Department of Education. In the 2015-16 year, 9,506 students were exempt.

New Jersey requires only a letter from a parent citing a religious exemption for schools and day care centers to grant them. Pediatricians and public health professionals have argued that exemption is really a philosophical one because most religions do not oppose vaccines.

Christian Scientists, who rely on prayer more than medical interventions, “are free to make their own choices on all life-decisions, in obedience to the law, including whether or not to vaccinate their children. These aren’t decisions imposed by their church,” according to the Christian Science website.

Many opponents say they have opted-out because embryonic tissue extracted from aborted fetuses in the 1960s is used to make the measles, mumps, rubella (MMR) vaccine. Others said they mistrust the medical and pharmaceutical industries and say that God had created their bodies strong enough without vaccines. They say the measure violates their First Amendment rights.

Should the bill pass Monday, Murphy, the state’s Democratic governor, to decide whether to sign it into law or veto it. The law would take effect six months after he signs it.

New Jersey would be the sixth state to pass such a law. California, Maine, Mississippi, New York, and West Virginia have eliminated religious exemptions.

Asked about the measure during an unrelated event in Saddle Brook last month, Murphy would not say whether he’d sign it. Instead, he said “the safety of all nine million residents is job No. 1 for me, and in particular our kids.”

EDITOR’S NOTE: This story has been changed to reflect official position on vaccines by the Christian Science religion.

NJ Advance Media staff writer Blake Nelson contributed to this report.

Thousands of protesters gather outside the Statehouse in Trenton on Thursday to protest the vaccination bill.Patti Sapone | NJ Advance Media

Susan K. Livio may be reached at slivio@njadvancemedia.com. Follow her on Twitter @SusanKLivio.

Brent Johnson may be reached at bjohnson@njadvancemedia.com. Follow him on Twitter @johnsb01. Find NJ.com Politics on Facebook.

Have a tip? Tell us. nj.com/tips

Get the latest updates right in your inbox. Subscribe to NJ.com’s newsletters.