Although school boards in Hokkaido, Japan’s northernmost island, and Osaka, Japan’s third-largest city, had already moved to close schools, Mr. Abe’s announcement took parents and analysts by surprise.

“It seems really extreme and really sudden,” said Chelsea Szendi Schieder, an associate professor of economics at Aoyama Gakuin University in Tokyo. “And the implications for people and their daily lives is going to be so big that I’m not sure it’s worth it in terms of public health.”

Kentaro Iwata, an infectious-disease specialist at Kobe University who had criticized the government’s response to the coronavirus outbreak on the Diamond Princess, said school closings were not medically warranted.

[Read: As its coronavirus cases dwindle, China is turning its focus outward.]

“I don’t understand this,” Dr. Iwata said. “Primarily, children are not easily infected with coronavirus, and even if they are infected, they don’t easily fall seriously ill.”

Analysts said political calculations might have weighed more heavily than science, particularly with the Olympics scheduled to begin in July.

“The Olympics have cast a shadow over the government’s response this whole time,” said Tobias Harris, an expert on Japanese politics at Teneo Intelligence in Washington.

“Early on, the response was a little timid and reactive for fear of alienating international visitors,” he said, “and now they’re belatedly realizing that unless they can somehow stop this or contain it that the chances of cancellation seem to be growing by the day.”