Fire investigators say a candle sparked the flames that ripped through a Manhattan apartment building Thursday night, hurting nearly two-dozen people.

Flames broke out at a 33-story building at 515 West 59th Street just before 5 p.m.

Officials say a candle lit a woman's clothes, leading to a disaster.

"She was wrapping Christmas gifts, and she had a bathrobe, loose clothing on, and some candles in the room, and the candles caught fire to her clothing. She removed the clothing and threw that on the floor or on a couch, I believe, and left the apartment. In doing so, she left the apartment door open," said Borough Commander Roger Sakowich of the FDNY.

Seventeen people were hurt, with two suffering critical injuries.

A 7-year-old girl had to be revived after she went into cardiac arrest.

Four firefighters were hurt as well, including one who suffered serious burns.

"I saw there was smoke, and then somebody called from upstairs, 'Call 911, call 911,'" one resident said.

"I knew enough to bring this wet towel and then cover the bottom of my door with wet rags, open the window and breathe through the window, because the smoke was coming in so quickly into my apartment," resident Vicky Barja recalled.

Fire officials said the four-alarm blaze started in a one-bedroom apartment on the third floor.

"We had heavy fire conditions on the third floor that basically incinerated a one-bedroom apartment. We had heavy winds blowing into the apartment," FDNY Chief of Department James Leonard said.

Those winds helped spread heavy smoke into the upper floors of the building.

Officials said the building is fireproof, so residents who stayed in their apartments were better off than those who tried to evacuate.

Authorities said some of the victims went to the roof during the fire, something officials say residents should not do.

Officials returned to the building Friday to teach residents about fire safety. 

They say it's crucial not to leave open flames unattended, and close any doors to contain a fire.