New York City’s public schools will remain closed through the end of the academic year because of the coronavirus, Mayor Bill de Blasio said on Saturday, confirming a disastrous scenario that he had previously warned of: more than three months of regular schooling for 1.1 million children would be lost.

Roughly 1,800 schools across the city’s five boroughs have scrambled to adjust to remote learning since they were initially shuttered on March 16, a sudden shift that has presented educators with perhaps the largest challenge of their careers and turned well over one million parents into part-time teachers.

The first few weeks of online learning have already transformed the relationships among the city’s students, parents and educators, who have come to rely on one another in ways unfathomable even a month ago.

“Lord knows, having to tell you that we cannot bring our schools back for the remainder of this school year is painful,” Mr. de Blasio said during a news conference. “But I can also tell you, it’s the right thing to do.”