“They went to get oxygen and I just stayed there rubbing his chest,” he said. “I rubbed his chest.”

Firefighters carried out two more unconscious victims: a man with smoke rising off his clothes, and a woman who appeared to have been burned.

In all, five people were found dead inside the building, all on the third and fourth floors.

Seven others were pronounced dead at nearby hospitals. The authorities had not yet officially released the names of the victims.

Temperatures were in the teens on Thursday night, and stiff winds made it feel below zero. Water leaking from hoses froze in streaks on the concrete as displaced residents walked around draped in American Red Cross blankets.

The building had open violations for a broken smoke detector and carbon monoxide detector in a first-floor apartment, according to city records. But Mr. de Blasio said those issues did not appear to be related to the fire.

The 12 fatalities made the fire the deadliest since an inferno at the Happy Land Social Club — less than a mile from Thursday’s blaze — killed 87 people in 1990. Thursday’s toll surpassed that of a 2007 blaze in the Bronx caused by an overheated cord that killed 10 people, nine of them children.

Hours after the Bronx fire, another fire tore through a building in Bedford-Stuyvesant, Brooklyn. Two more men died, the 23rd and 24th fire fatalities this December.