New York City has postponed the start of school for more than 1 million students amid pressure from a teachers union, which said there was not enough time to ready educators and school buildings to teach students safely during the pandemic.

Mayor Bill de Blasio (D) announced he had reached a deal with the unions representing teachers, principals and food workers to delay reopening for nearly a week, beginning virtual classes for all students on Sept. 16 and in-person classes for some students five days later. School was originally slated to start Sept. 10. Students were given the option of full-time remote classes or a hybrid model — returning to school part-time but taking classes virtually the rest of the time. About 37 percent of students have opted for the all-virtual classes.

His decision came after increasing pressure from the United Federation of Teachers, whose members threatened to strike or take the city to court if the mayor fell short of meeting their health and safety demands. What happened in New York City may foreshadow how fights between teachers unions and elected officials over school reopenings play out in other cities.

“New York City is taking the best practices, the strongest methods from all around the world and applying them here, in our public schools, the highest standard anywhere in the world to protect our kids, our families, our educators, our staff,” de Blasio said in a news conference.

The city’s school system faces a number of challenges, including ensuring that classrooms have adequate ventilation and staggering attendance to allow for social distancing. The city was also still working through how teachers would provide both in-person and virtual instruction.

The city, once the nation’s epicenter of the pandemic, has lost more than 19,000 people to covid-19, and its residents fear another outbreak. But de Blasio said he believes the city has made enough progress against the novel coronavirus that students, many of whom rely on schools for food and refuge, can safely return for face-to-face instruction. Its most recent positivity rating — the percentage of those tested who had contracted the virus — was 1.3 percent, a fifth of the national average.

Reopening schools would mark an incredible milestone for the city, where sirens once echoed constantly and refrigerated trucks had to be set up outside hospitals to handle the dead. It is one of the only urban systems to welcome students back to school buildings.

The postponement comes as districts around the country grapple with the start of the school year, with virtual learning hampered by technology glitches and in-person learning threatened by growing numbers of infections among young people.

President Trump, who has made clear that reopening schools is key to restarting the economy and boosting his reelection bid, has pushed for it even in coronavirus hot spots. Trump-aligned officials in Georgia and Florida have reopened schools contrary to public health advice, and many have been forced to quarantine hundreds of children and employees as infections emerge.

But officials in New York City, a Democratic stronghold, have been critical of Trump. On Tuesday, Michael Mulgrew, president of the United Federation of Teachers, reiterated the frustration over the fractured federal response.

“The story of the public school systems across the United States and what the federal government has done will go down as one of the biggest national disgraces,” Mulgrew said. “The federal government has failed to act, yet no one had any qualms about standing up at press conferences saying how important it is for schools to reopen.”

The teachers union last month laid out its demands for the city, including testing for every student and educator who would enter school buildings and putting a nurse in every school. It also said teachers would not show up to buildings unless the union’s health and safety inspectors signed off.

The city was already working toward hiring more school nurses, and it agreed to a program that will test a random sample of employees and students, with parental permission, at every school on a monthly interval.