Harvard University plans to invite about 3,100 undergraduates to its campus in Massachusetts for the spring semester, roughly double the number that lived there this fall under the extraordinary public health limits tied to the coronavirus pandemic.

Under a plan released Tuesday afternoon, all seniors would get priority for housing as well as juniors who were enrolled in the fall and certain other groups with special circumstances. Among them are students who live in time zones four or more hours removed from Eastern time.

This fall, about 1,500 students lived on the campus in Cambridge, mostly freshmen. All of Harvard’s undergraduate courses are being taught remotely throughout the school year.

In ordinary times, Harvard would house a little more than 6,600 undergraduates. This year the university is limiting its housing density, allowing no more than one student per bedroom, in an effort to prevent spread of the novel coronavirus. It also is frequently testing those who live on campus to detect possible outbreaks.

University officials said the testing had detected 38 positive virus cases this semester among students and others living on campus, far fewer than they had anticipated.

“A single positive case is too many,” Harvard President Lawrence Bacow and other leaders wrote in a message to the community. “Nevertheless, we are greatly encouraged by this outcome and grateful to the students in our campus community this fall who deserve enormous credit for it. With vigilance and resolve, they embraced Harvard’s public health protocols and put the community’s safety first.”

Bacow’s note acknowledged that many students, especially those in their second year, will be disappointed. “We know that this news will be particularly difficult for sophomores and their families as they confront the reality of a full academic year away from campus,” the Harvard president wrote. We share their disappointment and are eager to bring sophomores, and our full student community, back as soon as possible.”

Last week, Princeton University announced that it was inviting all enrolled undergraduates to its campus in New Jersey in the spring term. Housing plans this fall in the Ivy League and elsewhere have varied widely as schools decide how many students they can accommodate.