Mr. Louire said he was told not to turn on a cellphone or anything else, and to leave the apartment and the building, at 1652 Park Avenue. He was in the lobby when he heard the explosion.

Elizabeth Matthews, a spokeswoman for the utility, confirmed that a customer at 1652 Park Avenue called to report a heavy gas odor at 9:13 a.m. Two minutes later, two Con Ed crews were dispatched, and they arrived just after the explosion.

The Fire Department said it received the first report of a fire at 9:31 a.m., and discovered on arriving two minutes later that the buildings had collapsed. There were a total of 15 apartments in the two buildings; one had a church on the ground floor, and the other had a piano store.

The buildings were five stories and about 55 feet tall, according to Buildings Department records.

The injured were taken to several area hospitals; most were treated and released. Officials said 13 people went to Harlem Hospital Center, including a 15-year-old boy in critical condition; 22 people at Mount Sinai Hospital, including a woman in critical condition with head trauma; and 18 at Metropolitan Hospital Center, all with minor injuries.

City officials urged families trying to find loved ones to call 311. Many congregated at a center set up by the Red Cross at a nearby school, even as they made appeals on social media for information about the missing.

About 250 firefighters from 44 units responded to the explosion. Heavy equipment was used to clear destroyed vehicles outside the buildings as firefighters started the painstaking task of searching the rubble brick by brick. By late afternoon, they could be seen sifting through the wreckage, passing buckets of debris hand to hand to clear it from the site. As night fell, there were still hot spots in the debris that limited rescue efforts.