An aging steam pipe exploded and spewed cancer-causing asbestos in Manhattan’s Flatiron District on Thursday morning, shutting down several blocks of Fifth Avenue and forcing the evacuation of nearly 50 buildings.

One firefighter suffered serious injuries, the FDNY said. Another firefighter, at least four cops and six civilians had minor injuries, with six refusing medical attention.

A massive plume of scalding steam erupted through the street at Fifth Avenue and West 21st Street at around 6:40 a.m., with Mayor de Blasio saying the timing proved miraculous in preventing a far worse disaster.

“Thank God this happened so early in the morning, that there were many fewer people present than would normally be at that intersection if it were to have happened even just a couple of hours later,” he said.

The 20-inch main that blew was installed in 1932, FDNY Commissioner Daniel Nigro said. The cause of the blast remained under investigation.

The explosion coated cars, utility poles and buildings with asbestos-tainted mud and left a pile of rubble around a crater that Con Ed President Tim Cawley estimated at 15 by 20 feet.

Ceesay Sering, 56, was emptying trash cans for the Flatiron/23rd Street Partnership Business Improvement District when he saw the asphalt burst open.

“It was like the street just blew up,” Sering recalled.

He said he stopped a co-worker from crossing the street when he saw what he thought was smoke seeping through it.

“I told him, ‘Look, look, look,’ and then I told him, ‘Don’t go, don’t go,’ and then, as soon as I said that, it was just, boom!” he said.

De Blasio said testing showed the ruptured pipe was encased in potentially deadly asbestos insulation.

While the air “cleared fairly quickly,” officials were worried about “the debris that was thrown off” and the possibility that asbestos fibers were sucked into the heating, ventilation and air-conditioning systems of buildings, de Blasio said.

Officials evacuated 28 buildings in a “hot zone” at greatest risk of asbestos contamination, and another 21 in a “warm zone” farther away.

Neighborhood resident John Roberts said he “wasn’t scared” as he shot cellphone video of the steam, which “looked like a geyser of smoke going up in the air.”

“I had to shower and hand in my clothes to those guys,” he said, pointing to NYPD cops in white hazmat suits.

In an evening update, the Office of Emergency Management said 44 buildings were being checked for contamination, with about 500 residents displaced from 249 apartments.

Dr. Herminia Palacio, the deputy mayor for health and human services, said there was a “very, very low risk of any health impact from any onetime, limited exposure” to asbestos. But she said it was crucial to “reduce any long-term exposure.”

And de Blasio urged anyone who was near the blast to shower and put the clothes they were wearing in plastic bags and turn them over to Con Ed for compensation.

Con Ed said it would also take clothing from “anyone who was outside the immediate area of the rupture but who wants to exercise an abundance of caution.”

De Blasio said there had been no construction work at the site by any “agency or utility” in recent days, and OEM Commissioner Joseph Esposito said a permit issued by the Buildings Department allowed for work only on a water main across Fifth Avenue.

“So that permit and that work appears right now to have nothing to do with the steam rupture,” Esposito added.

Con Ed has 105 miles of mains and service pipes that carry steam to 1,800 customers in the city, with uses including heating buildings, making hot water and generating electricity for cooling units.

Asked how it inspects the aging system, Con Ed said it remotely monitors pressure at “select locations” and keeps tabs on “water levels in structures within defined flood zones or structures known to have water-infiltration issues.”

“This system is monitored on a 24/7/365 basis and alarms are responded to accordingly,” spokesman Alfonso Quiroz said in an e-mail.

Robert Weitz, owner of the RTK Environmental Group testing company, said steam pipes can rupture “at any point in time because of the aging infrastructure we have in New York.”

“Sooner or later, that material is going to deteriorate, and it’s going to break,” he said.

“Is it possible that anything like this could happen on any given day? Of course it is.”

In 2007, a Con Ed steam pipe exploded near Grand Central Terminal, causing the death of Lois Baumerich, 51, of Hawthorne, NJ, who suffered a heart attack as she fled in panic. About 40 others were injured.

Additional reporting by Elizabeth Rosner