New York City’s Department of Education on Friday faced mounting pressure from local lawmakers to shut the nation’s largest public-school system over the novel coronavirus, as student attendance plummeted.

Mayor Bill de Blasio said at a press conference Friday that the city’s school system would remain open and only close as a last resort, noting that such a decision would affect more than a million children and place a strain on their families and caretakers, some of whom are first responders and health-care workers.

“You have to be ready for the possibility that if schools shut down, it could be it for the school year and also the calendar year,” the mayor said. “The prism that I am looking through is war.”

Mr. de Blasio acknowledged that parents were already keeping their children home, but said “many, many parents want us to keep school open.”

On Friday, student attendance in the public schools had fallen to 68%, well below the yearly average attendance rate of 93% recorded by the city for the 2018-19 school year.