In another shift, the C.D.C. made clear that masks could be optional for vaccinated people, in line with its recommendations for the general public.

Still, the agency said that schools may opt to require universal masking if local cases were rising, for example, or if a school could not determine how many of its students and staff members were vaccinated. And it urged schools to “be supportive of people who are fully vaccinated, but choose to continue to wear a mask.” In general, students and staff members did not need to be masked when outdoors, the agency said.

The C.D.C. also strongly urged schools to promote vaccination, which the guidance called “one of the most critical strategies to help schools safely resume full operations.” Studies suggest that vaccines remain effective against the Delta variant.

The country’s two major teachers’ unions, which have close relationships with the Biden administration, praised the guidance. Randi Weingarten, the president of the American Federation of Teachers, whose members in some cases fought the reopening of schools this past school year, said the recommendations are “grounded in both science and common sense.”

Still, both school and public health officials predicted challenges ahead.

Ms. Weingarten said the mask guidance posed a particular test, since classes with students 12 and older would most likely include a mix of vaccinated and unvaccinated students. Many officials in areas with low vaccination rates have already said they will not require masks in schools — and at least eight states have already banned such requirements.

Some parents who have advocated school reopening greeted the new guidelines with relief. Meredith Dodson, whose son is entering kindergarten this fall in San Francisco, organized a group of parents who spent the last school year fighting for the city to open its schools. The city finally allowed elementary school students to return in mid-April, but most middle and high school students were not able to do so at all.

“This is a huge step in the right direction,” Ms. Dodson said.

Many schools have already largely or entirely returned to in-person learning. By mid-spring, the vast majority of districts had allowed at least younger students to return to classrooms, although many, especially on the West Coast, only allowed them to attend part-time. Many families — especially Asian American, Black and Hispanic families — chose to keep their children learning remotely.