After a measles outbreak that began at Disneyland late last year, lawmakers and public health officials began searching for ways to increase immunization in areas with low rates of inoculation. Across the state, only about 3 percent of children have not had vaccinations, but in some schools about half of all students have not gotten the vaccines recommended by most doctors.

“The majority of the state does the right thing, but you have these clusters of really low rates, and if there’s a vulnerable population in any way there, you can have serious problems quickly,” said Dr. Dean A. Blumberg, an authority on pediatrics and infectious diseases from the medical center at the University of California, Davis. “The parental choice question is big and important, but what is more important here is individual and larger public health. There is no doubt in the scientific community that there are no dangers in vaccines.”

Under the bill, families who do not want their children to receive vaccines for a nonmedical reason would have to home-school their children. Children who are currently in school without vaccines could remain, though they would be expected to show proof of vaccination when they enter kindergarten and seventh grade.

Image Spectators watched the debate from the Assembly gallery. The number of unvaccinated children in California has been rising. Credit... Max Whittaker for The New York Times

Some vaccine opponents predict a rise in home-schooling as a result of the measure.

Gov. Jerry Brown has not taken a public position on the bill but is widely expected to sign it. “The governor believes that vaccinations are profoundly important and a major public health benefit, and any bill that reaches his desk will be closely considered,” Evan Westrup, a spokesman for Mr. Brown, said in a statement.

Opponents have promised several legal challenges, including a claim that the legislation would violate children’s right to a free education, which is enshrined in the state Constitution. They have already begun several recall campaigns against legislators who pushed for the bill, including Mr. Pan.

Carl Krawitt, whose 7-year-old son, Rhett, is in remission from leukemia and was medically prohibited from receiving vaccines, argued that it was children like his son whose rights were being violated by those who refuse to vaccinate; unvaccinated children could pass along potentially deadly diseases to Rhett.