Stanford University canceled in-person classes for the final two weeks of the quarter, switching to online instruction amid rising concern about the coronavirus outbreak.

As the coronavirus first reported in China spreads in the United States, several schools have taken this step as a precaution, hoping to avoid further infections on campus. The University of Washington, which has more than 55,000 students on three campuses, announced Friday that it would switch to virtual classes, and some smaller schools in and near the hard-hit Seattle area, such as Pacific Lutheran University, announced similar plans.

On Sunday, Rice University in Houston canceled in-person classes for the week of March 9 and canceled gatherings of 100 or more people through the end of April. An employee tested positive for covid-19 last week after international travel, university officials said in issuing the alert.

“Like some of our peers, Rice is preparing for the possibility of delivering the majority of its classes remotely if that should prove necessary,” officials wrote in an alert to campus. Research will continue, they noted, because it is generally limited to small groups.

In New York, where multiple cases have been identified, Columbia University announced Sunday that classes are canceled Monday and Tuesday and that the university strongly discourages nonessential gatherings of more than 25 people. There are no confirmed cases among Columbia students, faculty or staff, but the Ivy League school’s president wrote that someone had been quarantined and that the suspension of classes will allow the school to prepare for a shift to remote classes for the remainder of the week.

Lee C. Bollinger, Columbia’s president, wrote in an email to campus: “Please understand that the decision to suspend classes does not mean that the University is shutting down. All non-classroom activities, including research, will continue in accordance with the new travel and events restrictions announced recently.” Bollinger said more information would follow about remote instruction from Wednesday through Friday, when spring break is scheduled to begin.

The decisions, which affect tens of thousands of students and faculty members, will be closely watched as university leaders grapple with how best to fight the outbreak.

Stanford’s campus remains open, with health care and other services available, and research continues, according to a message to students from a university official, but students are not required to be there.

It’s jarring to make these changes at the end of the quarter, as finals approach, said Courtney Douglas, a senior who was driving home to San Diego on Sunday with friends. She had packed clothing and books the night before, and students choosing to leave campus were essentially saying goodbye, unsure of when they would return, if at all, she said.

Seniors’ worries about finishing coursework remotely and being able to graduate to start jobs, Douglas added, are tempered by their understanding of the broader context of a global epidemic. “People are losing their lives to this,” she said.

Some students and others have worried that the campus in California was an increasingly unsafe place to be as covid-19 infections, the disease caused by the coronavirus, were reported nearby. An online petition calling for Stanford leaders to take action to prevent the spread of the virus on campus garnered more than 3,700 digital signatures. Another petition urged the university to “protect, inform, and fairly compensate workers” during the outbreak, because of the increased vulnerability of food service workers and custodians in particular.

The university’s president announced Thursday that Stanford Medicine was caring for a few patients with covid-19. The Stanford Daily reported that a faculty member in the Stanford School of Medicine had tested positive for the virus, citing an email from a dean to students.

Lisa Kim, a spokeswoman for Stanford Health Care and School of Medicine, said in an email that the person had not been in the workplace since experiencing symptoms, that the clinic in question had been closed temporarily for cleaning, and that people who had come in contact with the faculty member had been contacted and asked to isolate themselves to prevent spreading the infection.

Provost Persis Drell told the campus that starting Monday, for the last two weeks of the winter quarter, classes at Stanford will no longer meet in person and, as much as possible, they will be taught online. Exams will be administered as take-home tests rather than being given in a classroom setting. Drell acknowledged the sudden change would be a challenge for instructors and said the university is committed to helping them make the transition.

Susie Brubaker-Cole, Stanford’s vice provost for student affairs, wrote in an email to students that if they were planning to leave campus now or closer to spring break, “please keep in mind that the covid-19 situation is rapidly evolving, and this will likely continue for the foreseeable future. Travel will continue to be uncertain, and a range of factors may make it difficult for you to travel back.” She advised them to pack more heavily than they normally would, with travel delays in mind.

Douglas said some students were uncertain about potential risks, debating whether to fly home, stay on campus or embark on a long drive. The cost of last-minute travel was also an issue for some, she said.

Stanford also announced the university would not host admitted students on campus for the annual weekend welcoming them this year, typically a large and important event and one that had been planned for late April.

That added to the uncertainty for students about when normal life on campus might resume, Douglas said. “The future of the academic year is unclear.”

Hannah Knowles contributed to this report.