A state lawmaker says he is being subjected to personal attacks from antivaccine conspiracy theorists over a bill he is sponsoring to eliminate Massachusetts’ religious exemption for vaccinating schoolchildren.

Despite the deluge of angry mail and social media postings, state Representative Andy Vargas said he has seen an overwhelmingly positive response to his proposed legislation, galvanized by two confirmed measles cases in Massachusetts this year — and around 1,000 diagnoses nationwide.

More than 75 percent of vaccine exemptions in Massachusetts are for religious reasons, according to state data. The rest are medical exemptions, for health issues such as severe allergies or weakened immune systems, which still would be allowed under Vargas’s bill.

He said he was inspired by three separate constituent groups who told Vargas they felt unsafe sending their children to public schools.

“I have a duty to protect the general public and particularly people who are most vulnerable in our society,” the Haverhill Democrat said in a recent interview, adding that no major world religion is against vaccinations. “I felt that it was time to step up to the plate and respect the science.”

Vargas has enlisted bipartisan support of more than 20 lawmakers.

He is not alone in facing vitriol over his stance. Local doctors also say they are being attacked online for recommending parents vaccinate their children, with the attacks part of a coordinated effort by antivaccine groups.

Last month, the Massachusetts Medical Society’s House of Delegates passed a resolution opposing nonmedical vaccine exemptions for schoolchildren. Dr. Maryanne C. Bombaugh, the society’s president, said it is important to discuss — and later embrace — vaccinations by relying on accurate, transparent information.

“We have so much data, so much facts,” showing that vaccines are safe and effective, Bombaugh said. “It’s really a time to do this, address it, and get rid of fear — and to take care of patients, our children. I think this is very important legislation, and I applaud this coming forward.”

Dr. Ari R. Cohen, chief of pediatric emergency medicine at MassGeneral Hospital for Children, called Vargas’s bill a “brave move” amid a fiery political and religious debate surrounding vaccinations.

“It’s always a battle of the government’s view of what’s safe for its population,” Cohen said. “This is also a battle of your personal liberties. Unfortunately, it’s not just your personal liberty when it affects somebody else.”

Cohen said herd immunity — which can prevent contagious diseases from spreading if enough people in a community are vaccinated — has dwindled as the antivaccination movement gains momentum. That makes some groups more susceptible to contracting measles, a highly contagious viral infection that can linger in contaminated public spaces for hours.

“Vaccines are one of the true wins in medicine,” Cohen said. “The argument being made against vaccines is poor science and impassioned belief, and impassioned belief is hard to overcome.”

While C.J. Doyle, the executive director of the Catholic Action League of Massachusetts, believes in the “good of vaccines,” he described Vargas’s legislative push as “morally problematic.” As Doyle sees it, only parents — and not the government — should ultimately decide whether their children are vaccinated. “Our tradition has always been that people should be accommodated for their sincerely held religious beliefs,” Doyle said. “I think it’s unfortunate. I think our foundational liberty — our freedom of religion — is in some way being devalued and ignored.”

Massachusetts’ overall vaccination rate is about 95 percent, although exemption rates among kindergarten students vary widely across the state. In Suffolk County, less than half a percentage point are exempted. But in Dukes County, home to Martha’s Vineyard, the rate is 9.9 percent, according to 2018 state Department of Public Health statistics.

Measles, though considered eliminated nearly two decades ago in the United States, has seen a resurgence this year. Particularly hard hit have been Orthodox Jewish communities throughout New York, with over 550 cases in New York City and more than 250 cases in the suburb of Rockland County. Scientists believe the New York cases have origins in Ukraine and Israel.

Vargas said he’s confident his bill will succeed, citing comparable laws in Maine, California, Mississippi, and West Virginia that have already banned nonmedical exemptions.

“Given our proximity to New York, I don’t think we should wait for it to be a public health emergency,” Vargas said. “We want to take action.”