CAMBRIDGE, Mass. — Harvard University advised students not to return to campus after spring break and to expect to complete classwork remotely until further notice in an effort to avoid the spread of covid-19.

“Harvard College students will be required to move out of their houses and first-year dorms as soon as possible and no later than Sunday, March 15,” at 5 p.m., Rakesh Khurana, the dean of Harvard College told students Tuesday.

The change marked another sign of the impact of the coronavirus outbreak on even the most iconic institutions, as a growing number of universities known for their intense classroom debates, packed arenas and hands-on research are now moving to empty their campuses and avoid contact as much as possible.

Amherst College, the University of Washington and Princeton, Stanford, New York and Ohio State universities and others have announced dramatic changes in recent days in an effort to prevent infections by limiting the communal gatherings that have been central to campus life and learning at many schools.

Students, faculty and staff at all colleges are grappling with considerable uncertainty as the impact of the virus changes day by day. At Harvard, the announcement stunned students and set off a scramble for plane tickets and storage units among students, and efforts by faculty to upend their courses midstream.

“It’s devastating,” said Sanika Mahajan, a third-year student studying social studies and global health. “Everyone is reacting pretty quickly and emotionally.”

It felt like a descent into chaos, said Ajay Singh, a junior serving as a peer adviser who found himself trying to answer questions from international students and panicky first-years unable to afford travel home, when he had just woken up to the alert himself. He spent part of Tuesday stuffing random clothes into boxes and talking with other students about the “five-day eviction notice,” a phrase rattling around campus.

It created surreal scenes, Singh said, with some seniors strangely euphoric, effectively reminiscing and saying goodbyes in springlike weather on the lawn, while other students panicked.

In group chats, friends offered couches and basements for people in need, one student said.

“I don’t even really know how I feel,” said Sone Ntoh, an 18-year-old psychology major and football player from outside Philadelphia. “I’m still in shock about what happened. … It’s going to take a lot to get used to.”

What lies ahead is unknown. Mahajan is planning to move back home to the Bay Area in Northern California, where there have been numerous cases of covid-19. “There definitely is the fear that my community at home will be feeling unsafe and unsteady,” she said. “But at this time it seems the smartest course of action, for university students to not be all together on campus.”

Harvard is beginning to transition to virtual classes and hopes that transformation will be complete by March 23, the first day of classes after spring break, the school’s president announced to campus Tuesday.

Graduate students will transition to online work wherever possible, and students who must remain on campus will be taught remotely “and must prepare for severely limited on-campus activities and interactions,” the university’s president, Lawrence S. Bacow, wrote.

“We realize that leaving campus at short notice will be challenging for some of you,” Khurana wrote. He directed students whose home is in one of the countries most affected by the coronavirus outbreak or a country subject to the federal government’s travel ban to consult with a dean as soon as possible.

No cases of covid-19 have been detected at Harvard.

Claudine Gay, dean of the Faculty of Arts and Sciences, wrote to faculty members that the decision was made “to protect the health of our community, and it was not made lightly.” The changes were intended to minimize the need to gather in large groups and spend prolonged time close to one another in dorms, dining halls and classrooms. “The campus will remain open and operations will continue with appropriate measures to protect the health of our community,” she wrote.

“There is much we still do not know and the situation on the ground continues to evolve,” Gay wrote.

The idea that Harvard would switch to online classes seemed like an overreaction five days ago, Jason Furman, professor of the practice of economic policy at the Harvard Kennedy School of Government, wrote in a tweet Tuesday. “Today we made the obviously right decision to ask our undergraduates not to return after spring break.”

Furman wrote that he doesn’t think anyone in the United States will be sitting in a university classroom two weeks from now.

Furman, a former economic adviser in the Obama administration, added that if and when Harvard has a confirmed case of covid 19, “it will be too late. How do 6,700 undergraduates living in dorms and eating together in dining halls self isolate? How could we send them home then?”

Nonessential gatherings of more than 25 people on campus are strongly discouraged, Bacow wrote.

Gay asked that even smaller meetings be held remotely, or postponed, if possible.

Khurana told students that officials were working to get all classes online. “We are committed to ensuring that you will all be able to finish your spring term courses, and that you will remain on track to graduation,” he wrote.

The financial impact is unclear. Anticipating questions about whether refunds would be issued for room and board for the remainder of the semester, Harvard officials wrote on a website, “The University is still working on the details for what will happen with student charges. Please be patient as this will take some time and the priority is getting students home safely.”

Everyone is concerned for international students, Mahajan said, and for all of those who will have a difficult time affording such a sudden move. It’s not easy for anyone to move within days while juggling classes and academic work, she said.

The prospect of such an abrupt loss of campus home, social life, classes, extracurriculars, traditions, all the things that make up the college experience were overwhelming, she said. “My heart goes out to the graduating seniors,” and others who expected this to be their final spring on campus, Mahajan said.

“The more difficult part to process is the long term — what this means for the health of our country,” and how profoundly everyone, everywhere may be affected, she said. “We’re starting to think about what that might mean.”

In his letter, Bacow spoke to the fundamental change about to occur: He acknowledged to students, especially graduating seniors, that this was not how they expected their time at Harvard to end.

“We are doing this not just to protect you but also to protect other members of or community who may be more vulnerable to this disease than you are,” Bacow wrote.

He acknowledged to faculty they were being asked midway through the semester to completely rethink the way they are teaching.

Gay promised the faculty support. “This is hard stuff, and no one is in this alone,” she wrote.

“I am proud to be a member of a community where people put the greater good above their own self-interest,” Bacow wrote. “Thank you for your patience and your resilience as we all learn to temper increased distance with deeper care for one another.”

So much had changed, so fast: “We weren’t even thinking about this last week,” said Hannah Shin, who was walking through Harvard Yard after playing Frisbee with two other first-year students on an unseasonably warm day. They will miss moments like those the most, she said.

“There’s been lots of crying,” said Stephany Zhivotovsky.

Another friend walked by. Andres Mendoza, 19, of Panama, greeted him with a hug. “I guess I just broke every rule,” he said.

Nick Anderson and Hannah Natanson contributed to this report.