SACRAMENTO — Ending months of speculation on whether he would endorse the incendiary legislation, Gov. Jerry Brown this morning signed into law Senate Bill 277, which requires almost all California schoolchildren to be fully vaccinated in order to attend public or private school, regardless of their parents’ personal or religious beliefs.

California now joins only two other states — Mississippi and West Virginia — that permit only medical exemptions as legitimate reasons to sidestep vaccinations.

“The science is clear that vaccines dramatically protect children against a number of infectious and dangerous diseases,” Brown wrote in his signing message. “While it’s true that no medical intervention is without risk, the evidence shows that immunization powerfully benefits and protects the community.”

Sens. Richard Pan, D-Sacramento and Ben Allen, D-Santa Monica, co-authors of the legislation, soonafter addressed reporters at a news conference held at a Sacramento elementary school where most of the students are fully vaccinated.

“The science is clear. Californians have spoken. The governor and Legislature have spoken,” said Pan, who was surrounded by a crowd of several dozen beaming mothers and young children wearing “I heart immunity” stickers.

“No more preventable contagions. No more outbreaks. No more hospitalizations. No more deaths. And no more fear,” said Pan, who is a pediatrician. “(The bill) is now law.”

Asked if he thought California’s action would spark similar changes in other states, Pan said Brown’s swift action on the bill will send a “strong signal” across the country. Neither California nor any other state “wants to continue to see (outbreaks) happen in their neighborhoods,” Pan said.

But opponents who have rallied against the bill at the state Capitol, saying the legislation violates their parental rights, immediately vowed both to sue the state and take their case to California voters.

“We are going to have a referendum to ask the public to put a hold on the law,” said Palo Alto resident Christina Hildebrand, president and co-founder of A Voice For Choice. “We will continue to fight this — we are not going away,” said the mother of two unvaccinated children.

Under the law, vaccinations would be required of children first entering public school, or when they enter seventh grade, after July 1, 2016.

The clamor around the elimination of the “personal belief exemption” heated up in California after a measles outbreak started last December at Disneyland.

By the time they declared the outbreak over in mid-April, state health officials confirmed 136 measles cases in California. Nearly 20 percent of those cases required hospitalization. That’s something that Pan and Allen said could have been prevented if more Californians, particularly those in communities with low-vaccination rates, were fully immunized.

At the victory rally, Senate President Pro Tem Kevin de Leon, D-Los Angeles, held the 3-month-old son of his deputy chief of staff while thanking Pan and Allen for the “courage” they showed in taking up such a divisive issue.

Over the past four months as the Legislature debated the bill, Pan, Allen and other lawmakers who supported the bill were harassed and bullied by some opponents of the legislation.

Allen said that poor behavior “strengthened the resolve of our colleages” to get the bill passed and signed into law.

“They don’t like to be mistreated. They don’t like to be threatened. They don’t like to be bullied,” Allen said.

The bill has received widespread support from health and education organizations across the state, including the California Medical Association; the American Academy of Pediatrics, California; California State PTA; California Immunization Coalition; and the California Children’s Hospital Association.

Dr. Richard Thorp, immediate past president of the CMA, thanked the governor and the Legislature for their leadership in supporting the bill.

“SB 277 is based in fact and science and will help increase community immunity across the state,” Thorp said. “This is sound public health and we hope Governor Brown’s swift signature on the bill shows how important it is for California. We applaud his fast action to keep Californians safe.”

Brown’s decision Tuesday also aligns with the opinions of two-thirds of Californians, who believe children should not be allowed to attend public school unless they are vaccinated, according to a recent Public Policy Institute of California poll.

Still, opponents say the bill will be a hardship on many parents whose unvaccinated kids now can only attend private home schools or learn through independent off-campus studies. And, they say, some vaccines harm some children, and parents should have the right to protect their children.

Under the law, a physician has broad authority to grant a medical exemption, not only to children who have had severe reactions to vaccines in the past, but also if a family member had a bad reaction to a vaccine.