Investigators are trying to determine why safety doors failed to close in a New York City high-rise building when a deadly fire broke out.

The problem allowed thick smoke to billow through the tower and kill 17 people, including eight children, in the city's deadliest blaze in more than three decades.

Fire officials determined that an electric space heater started the fire on Sunday in the 19-storey building in the Bronx.

The flames damaged only a small part of the building, but smoke poured through the apartment's open door and turned stairwells into death traps.

The stairs were the only means of getting out in a building too tall for fire escapes.

City fire commissioner Daniel Nigro said the apartment's front door and a door on the 15th floor should have been self-closing and blunted the spread of smoke, but the doors stayed fully open.

It is not clear if the doors failed mechanically or if they had been manually disabled. Mr Nigro said the apartment door was not obstructed.

The heavy smoke blocked some residents from escaping and incapacitated others as they tried to flee, officials said.

Firefighters carried out children and gave them oxygen and continued their rescue efforts even after their air supplies ran out.

Glenn Corbett, a fire science professor at John Jay College in New York City, said closed doors are vital to containing fire and smoke, especially in buildings that do not have automatic sprinkler systems.

"It's pretty remarkable that the failure of one door could lead to how many deaths we had here, but that's the reality of it," Mr Corbett said.

"That one door played a critical role in allowing the fire to spread and the smoke and heat to spread vertically through the building."

Dozens of people were taken to hospital, including several who were in a critical condition.

New York mayor Eric Adams called it an "unspeakable tragedy" at a news conference near the scene on Monday.

"This tragedy is not going to define us," Mr Adams said. "It is going to show our resiliency."

The mayor lowered the death toll from an initial report on Sunday, saying that two fewer people were killed than originally thought.

Mr Nigro said patients were taken to seven hospitals and "there was a bit of a double count".

The dead included children as young as four years old, city council member Oswald Feliz said.

An investigation is under way to determine exactly how the fire spread and whether anything could have been done to prevent or contain the blaze, Mr Nigro said.

The building was equipped with self-closing doors and smoke alarms, but several residents said they initially ignored the alarms because they were so common in the 120-unit building.

Bronx Park Phase III Preservation LLC, the group that owns the building, said it is cooperating fully with the fire department and the city and working to assist residents.

"We are devastated by the unimaginable loss of life caused by this profound tragedy," the statement said.

New York City has been slow to require sprinklers for older apartment buildings, passing laws to mandate them in high-rise office towers after 9/11 but stalling in recent years on a bill that would require such measures in residential buildings.

In 2018, a city legislator proposed requiring automatic fire sprinklers in residential buildings 40 feet or taller by the end of 2029, but that measure never passed, and the lawmaker recently left office.

A sprinkler system set off by heat in the apartment might have saved lives, said Ronald Siarnicki, executive director of the National Fallen Firefighters Foundation.

"Most likely it would have extinguished that fire or at least held it in check and not produced the amount of toxic smoke," he said, adding that firefighter groups have been lobbying for stricter sprinkler requirements for years.

The building is home to many families originally from the Gambia in West Africa.

Resident Karen Dejesus said she was used to hearing the fire alarm go off.

"Not until I actually saw the smoke coming in the door did I realize it was a real fire, and I began to hear people yelling, 'Help! Help! Help!'" she said.

Ms Dejesus, who was in her two-floor apartment with her son and three-year-old granddaughter, immediately called family members and ran to get towels to put under the door.

But smoke began coming down her stairs before the 56-year-old resident could get the towels, so the three ran to the back of the apartment.

"It was so scary," she said. "Just the fact that we're in a building that's burning and you don't know how you're going to get out. You don't know if the firefighters are going to get to you in time."

Firefighters broke down her door and helped all three out the window and down a ladder to safety.

The fire was New York City's deadliest since 1990, when 87 people died in an arson at the Happy Land social club, also in the Bronx.

Sunday's fire happened just days after 12 people, including eight children, were killed in a house fire in Philadelphia.