William & Mary will require all students, faculty members and staffers to be vaccinated against the coronavirus, effective immediately, the school’s president announced Thursday — a sudden acceleration of a mandate that reflects the changing conditions of the pandemic nationally and a lower-than-expected reported rate of voluntary vaccination.

It’s a struggle that is playing out at colleges across the country, as university leaders try to gauge risk and balance students’ longing for normal campus life with the need to keep the community safe. Vaccine mandates have been challenged with lawsuits and protests at some schools, and some universities have avoided imposing them.

But a surge in virus cases driven by the highly infectious delta variant has changed the equation for some schools. Earlier this week, the closely watched California State University System, the country’s largest body of four-year public universities, announced that students and employees must be fully vaccinated to enter its campuses.

The University of Virginia and the University of Maryland are among the D.C.-area schools that also have mandated vaccines, while Catholic University in the District “strongly encouraged” students and employees in the spring to get inoculated.

At William & Mary, students and employees had been notified in May that vaccination would be required once the FDA gave full approval to at least one vaccine. Still, the public university in Virginia asked people to provide proof of their vaccination status if they intended to participate in in-person events in the fall. But earlier this week, school officials alarmed some parents and students with an email warning that the number who had registered as being fully vaccinated was well short of what was needed to resume more-normal operations in the fall.

Just 56 percent of students had registered as fully vaccinated by mid-July, according to the email sent to parents Monday from Vice President for Student Affairs Ginger Ambler and Chief Operating Officer Amy Sebring. They urged students to verify their vaccination status by the end of the day Wednesday and warned that unless vaccination numbers rose significantly, the university would need to impose changes that could include requiring universal masking as well as limits on social gatherings and athletic events.

That set off an outcry among parents. Some wrote on social media that they didn’t want their children to be forced to take experimental drugs. But many others urged the school to mandate vaccines.

“Without a mandate, the incentive for people to just blow it off is there,” said Rick Holt, an Arlington resident whose son is a William & Mary student who has been vaccinated. Holt said he was hoping students could have as normal a year as possible. “It was pretty miserable being in Williamsburg as a student last year,” socially, he said of the experience of his son and other students, with pandemic regulations limiting how students could get together, participate in activities, and make friends.

His daughter will be attending U-Va., and both of his children have been counting on typical college life this fall.

On Thursday, the university’s president, Katherine A. Rowe, wrote to campus, “Through the past month, as we planned for the Fall 2021 semester, we have been tracking the recent surge in cases nationally and the continued emergence of COVID-19 variants …”

She thanked students for updating their vaccine status with the school this week — more than three-quarters of students had verified they were fully vaccinated, she wrote Thursday. Still, “W & M’s current rates are not sufficient to safeguard our community during in-person activities this fall,” she wrote.

Given the changing public health context, she wrote, the school had updated its vaccine requirements effective immediately. Students must report their first shot, or apply for an exemption, by Aug. 10, Rowe said, or they cannot live on campus or take classes. Employees face being sent on leave without pay or being fired if they do not get vaccinated against the novel coronavirus or record an exemption with the school.

Holt’s son texted him when he heard the news, relieved. Holt was pleased, calling the school’s decision a slam-dunk. “From a public health perspective, we want to be incentivizing people to do the right thing” and get vaccinated for everyone’s safety, he said.

Mary Roth, a parent from New York, had been worrying about her son’s having to live with an unvaccinated fellow student. “I’m just thrilled this is the outcome,” she said Thursday after seeing the changed policy. “As a doctor, I know that this thing is mutating all the time. It’s getting worse and worse. …

“I’m relieved but also still very anxious.”