New York City is shuttering schools to try to stop the renewed spread of the coronavirus, Mayor Bill de Blasio said Wednesday in a painful about-face for one of the first big U.S. school systems to bring students back to classrooms this fall.

The nation's largest public school system will halt in-person learning Thursday, sending more than 1 million children into all-online classes at least through Thanksgiving, the Democratic mayor said at a news conference.

The city hasn't yet settled on criteria for reopening classrooms, but de Blasio said they would involve increasing virus testing of children at schools and allowing students to return only if their parents consented to that testing.

“We're going to fight this back,” de Blasio said. “This is a setback, but it's a setback we will overcome.”

He'd said last week a shutdown could come within days. Still, it came as a blow to parents such as Darneice Foster. She has four children, ranging in age from 4 to 13, now set to be learning from home.

“I don't know what I'm going to do, except pull my hair out,” she said.

The city's springtime stretch of all-online learning was “really awful” for the family, which shares a one-bedroom apartment in Upper Manhattan, said Foster, a former pharmaceutical advertising worker who left her job some years ago when one of her children had health problems.

“Now, I really want my kids to catch up, and I'm one person,” she said. She said she would “look on the sunny side and just bear it for a few weeks,” hoping schools would reopen soon and looking for ways she might be able to improve her children's remote-learning experience.

The city had said since summer that school buildings would close if 3% of all the coronavirus tests performed citywide over a seven-day period came back positive, setting a far stricter standard than did many other school systems that have opened classrooms.

The mayor said the rate equaled that mark as of Tuesday. In fact, a revision of earlier city data, as slower-returning test results came in, showed it had likely been above that threshold since Nov. 11.

Most of the city's public school students are already being taught online. As of the end of October, only about 25% had attended class in person this fall. Even those students learn from home part of the week, a measure taken to keep children spread out in school.

Many of them and their parents prize their in-school days, and some families have protested the idea of shutting schools.

“They're still keeping indoor dining and gyms open, and nail salons and hair salons. ... Schools should be the last thing to close,” said Carly Maready, who has three children in kindergarten through fifth grades. She helped organize a parents' group that held a rally Saturday and planned to deliver a petition Thursday at City Hall.

With random testing of students and staffers showing little indication that the virus is spreading within schools, closing them is “tone-deaf to everything that parents in New York City are going through,” said Maready, who lives in Upper Manhattan's Inwood neighbourhood and works in philanthropy.

New York City's school system, like others across the nation, initially halted in-person learning in mid-March as the virus spiked. In-person school resumed Sept. 21 for pre-kindergarteners and some special education students. Elementary schools opened Sept. 29 and high schools Oct. 1.

At the time, the seven-day positive test average rate was under 2%.

Even as the school system stayed open, nearly 1,500 classrooms went through temporary closures after students or staffers tested positive, and officials began instituting local shutdowns in neighbourhoods where coronavirus cases were rising rapidly.

As of midweek, more than 2,300 public school students or staffers had tested positive since the start of the school year.

While many big U.S. school districts had decided to start the fall term with online learning, de Blasio pushed for opening schoolhouse doors. He argued that students needed services they got in school and that many parents were counting on it in order to get back to work.

The reopening date, originally set for Sept. 10, was postponed twice as teachers, principals and some parents said safety precautions and staffing were inadequate, with the teachers' union at one point threatening to strike.

The city agreed to changes, including hiring thousands more teachers and testing 10% to 20% of all students and staffers per month for the virus.

When high schools finally opened their doors, de Blasio hailed it as “an absolutely amazing moment” in the city's recovery.

New York Gov. Andrew Cuomo, who has frequently overruled the mayor on major decisions related to the pandemic, said Wednesday the city had the authority to shut things down.

Cuomo predicted a “tremendous spike” in COVID-19 cases after Thanksgiving and pleaded with people to be careful.

“Your dining room table at Thanksgiving sounds safe,” the Democrat said at a news briefing in Albany. “No, you won't be safe. It's an illusion.”

With hot spots flaring around the state, Buffalo and surrounding towns in western New York will enter what are known as “orange zone” restrictions, in which schools go remote and “high-risk” businesses such as gyms are closed, Cuomo said. The areas had been in less restrictive “yellow” zones.

Associated Press writers Karen Matthews in New York and Marina Villeneuve in Albany contributed.