For more than 40 years, Mississippi had one of the strictest school vaccination requirements in the nation, and its high childhood immunization rates have been a source of pride. But in July, the state began excusing children from vaccination if their parents cited religious objections, after a federal judge sided with a “medical freedom” group.

Today, 2,100 Mississippi schoolchildren are officially exempt from vaccination on religious grounds. Five hundred more are exempt because their health precludes vaccination. Dr. Daniel P. Edney, the state health officer, warns that if the total number of exemptions climbs above 3,000, Mississippi will once again face the risk of deadly diseases that are now just a memory.

“For the last 40 years, our main goal has been to protect those children at highest risk of measles, mumps, rubella, polio,” Dr. Edney said in an interview, “and that’s those children that have chronic illnesses that make them more vulnerable.” He called the ruling “a very bitter pill for me to swallow.”

Mississippi is not an isolated case. Buoyed by their success at overturning coronavirus mandates, medical and religious freedom groups are taking aim at a new target: childhood school vaccine mandates, long considered the foundation of the nation’s defense against infectious disease.

Until the Mississippi ruling, the state was one of only six that refused to excuse students from vaccination for religious or philosophical reasons. Similar legal challenges have been filed in the five remaining states: California, Connecticut, Maine, New York and West Virginia. The ultimate goal, according to advocates behind the lawsuits, is to undo vaccine mandates entirely, by getting the issue before a Supreme Court that is increasingly sympathetic to religious freedom arguments.

No major religions, including Roman Catholicism, which strongly opposes abortion, have objected to vaccination. But the plaintiffs in these cases say their religious objections stem in part from the use of fetal tissue in vaccine development. A few childhood vaccines, including those that protect against chickenpox and rubella, were developed with cells obtained from aborted fetuses in the early 1960s. Those cells continue to grow in laboratories today.

The legal push comes as childhood vaccine exemptions have reached a new high in the United States, according to a report released last month by the Centers for Disease Control and Prevention. Three percent of children who entered kindergarten last year received an exemption, the C.D.C. said, up from 1.6 percent in the 2011-12 school year.

Idaho had the highest rate of exemptions, at 12.1 percent, while West Virginia had the lowest, at less than one-tenth of 1 percent. Mississippi’s rate was nearly as low, at two-tenths of 1 percent. At the time, Mississippi allowed exemptions for medical reasons, as all states do, but it did not yet allow parents to opt out on religious grounds.

A broad majority of Americans continue to believe in the value of childhood vaccines. But in a Pew Research Center survey conducted in March, 28 percent of respondents said that parents should be able to choose not to vaccinate their children, up 12 percentage points from four years ago.

In California, a group of parents backed by Advocates for Faith & Freedom, a nonprofit group devoted to religious liberty, filed suit in federal court in October seeking to restore the state’s “philosophical” exemption, which was eliminated after a measles outbreak in 2015. A federal judge recently allowed a similar case to go forward in Maine, which ended its religious exemption in 2021.

Connecticut, which also did away with its religious exemption in 2021, has faced legal challenges backed by We the Patriots USA, a group based in Idaho. In August, a divided federal appeals court rejected a constitutional challenge to the state law, and on Friday, a federal judge dismissed a second lawsuit. Brian Festa, a founder of We the Patriots, said in an interview that his group would ask the Supreme Court to take up the question.

“We’re looking for a broader ruling from the high court that says all children in the United States should be allowed exemptions to childhood vaccinations,” Mr. Festa said, adding that allowing exemptions for medical but not religious reasons was “a major constitutional problem.”

If vaccination rates dip much below 95 percent, public health experts warn, those diseases will become more than just a memory.

“It’s a dangerous game we’re playing,” said Dr. Paul A. Offit, the director of the Vaccine Education Center at Children’s Hospital of Philadelphia. “If we eliminate school vaccine mandates, measles will be the first vaccine-preventable disease to come back, and it will come roaring back. Why would we want to put children in harm’s way again?”

The Mississippi case offers a window into the political forces shaping these trends. The plaintiffs in the case included members of Mississippi Parents for Vaccine Rights, a group founded in 2012 by MaryJo Perry, who said in an interview that her path into advocacy began after her youngest son, now 20, experienced seizures following routine vaccination.

Seizures are a rare occurrence after vaccination. A large-scale study of more than 265,000 children identified 383 who had vaccine-related seizures, or less than two-tenths of 1 percent. Nearly all children who have post-vaccination seizures recover completely.

Ms. Perry said that while her son had not had ongoing issues, the experience was terrifying. She said her son’s pediatrician repeatedly requested a medical exemption from the state health department but was refused. (Dr. Edney said that Mississippi’s current practice was to grant a medical exemption if a doctor requested one.)

“I felt like it was a nightmare, like I was being terrorized by my own government,” Ms. Perry said.

Mississippi had a religious exemption until the state’s Supreme Court struck it down in 1979, reasoning that protecting Mississippi schoolchildren “against the horrors of crippling and death” from polio and other infectious diseases superseded religious claims. The state has had high childhood vaccination rates as a result.

“For many, many years, it was one of the few things that Mississippi has done well,” said Dr. Anita S. Henderson, a pediatrician in Hattiesburg and a past president of the state’s chapter of the American Academy of Pediatrics. “About 99 percent of our kindergartners have been fully vaccinated, and Mississippi has not seen a case of measles in over 30 years.”

Ms. Perry and members of her group tried for years to change the law. They marched with signs and empty strollers around the State Capitol and held lobbying days to push Mississippi’s Republican-controlled Legislature to add a “personal belief” exemption to state law. But the legislation never passed.

In 2016, Ms. Perry met Del Bigtree, a former television producer who had partnered on a documentary with Andrew Wakefield, the British doctor behind the discredited theory that vaccines are linked to autism. Their film, “Vaxxed,” took aim at the drug industry and was a hit with Ms. Perry’s group. Mr. Bigtree later traveled to Mississippi to testify on behalf of legislation that the organization was supporting to expand vaccine exemptions.

In an interview, Mr. Bigtree said the success of the film prompted him to found the Informed Consent Action Network. The group, based in Texas and known by the acronym ICAN, says its mission is to give people “the authority over your health choices and those of your children” and to put an end to “medical coercion.” It funded the Mississippi lawsuit, and tax filings show it spends millions of dollars on legal work.

Mr. Bigtree says his work is nonpartisan. But on Jan. 6, 2021, he addressed a “medical freedom” rally not far from the pro-Trump crowd that stormed the U.S. Capitol.

“I would stand on the stage at the Democratic National Convention if they would allow me,” he said in the interview, adding: “I don’t want mandates. It’s a free country. Everybody should be able to make whatever choice they want.”

But public health experts say that the purpose of vaccination is to protect entire communities and that making immunization a personal choice puts vulnerable people, including those who cannot get vaccinated for medical reasons, at risk. Last year, a measles outbreak in Ohio infected 85 children, nearly all of them unvaccinated. No one died, but 36 children were hospitalized.

States have long had the legal authority to require vaccination as a condition of school enrollment. As far back as 1905, the Supreme Court ruled in Jacobson v. Massachusetts that a state had the right to “protect itself against an epidemic” by requiring citizens to be vaccinated against smallpox or pay a fine.

But the coronavirus pandemic, and in particular the arrival of Justice Amy Coney Barrett on the Supreme Court, brought a “dramatic shift” in public health jurisprudence — especially in cases involving religious liberty, said Wendy E. Parmet, an expert in public health law at Northeastern University.

The Mississippi case was filed last year, and Dr. Edney, the state health officer, was one of the defendants. Ms. Perry was not a plaintiff; her children are grown. But she connected some of her members with Aaron Siri, a New York lawyer who handles much of ICAN’s legal work.

During a hearing in April in Federal District Court in Gulfport, Paul Perkins, a Baptist pastor, testified that the state’s vaccination requirement prevented him from enrolling his own daughter in the Christian academy that he runs. Jeana Stanley, a doctor of physical therapy, and Brandi Renfroe, a court reporter, testified that even though they and their husbands worked in Mississippi and considered that state home, they had moved just across the border to Alabama so their unvaccinated children could attend school.

“I put my trust in God for healing,” Dr. Stanley wrote in an affidavit, adding that she and her children avoided “physicians, medications (both over the counter and prescription) and vaccines.”

The case put Dr. Edney and the Mississippi State Board of Health at odds with the state attorney general, Lynn Fitch, a Republican who argued that an existing religious freedom law required the state to offer religious exemptions.

At the hearing in April, the judge, Halil Suleyman Ozerden, an appointee of President George W. Bush, ordered the state to begin accepting requests for religious exemptions, setting a mid-July deadline for Dr. Edney to set up a process for offering them.

“Freedom wins again,” Mr. Siri wrote on Twitter.

The judge made his ruling final in August, finding that Mississippi’s vaccination requirement had violated the constitutional rights of the plaintiffs, who he said had “sincerely held religious beliefs about vaccination.” Dr. Edney said he decided not to appeal. He said he feared that the case would go to the Supreme Court and that the state’s vaccination requirement would be struck down entirely.

Instead, he said, the state is working to ensure that parents seeking exemptions have “deeply held” beliefs, including by requiring them to watch an educational video about “the millions of lives that have been saved and continue to be saved” by vaccination.

Mr. Bigtree hailed the suit as a “landmark, historic case.” In the wake of its victory, his group trumpeted its support for similar legal challenges in other states.

Ms. Perry said Mississippi Parents for Vaccine Rights was working to elect candidates who are “pro-medical freedom.” She said she saw the court ruling as the culmination of a decade of her hard work, coupled with a new political climate.

“We’ve had many parents for years wanting to sue, and it was just not the right time,” she said. “Covid kind of set the stage in the judiciary for it to happen.”