In addition to the heavy flames, firefighters had to battle the extreme heat.
The fire broke out at the building on South Third Street in Williamsburg.
The fire was confined to the area between the ceiling of the top floor and the roof, and flames shot out the top of the building as firefighters labored to carry all their heavy gear up the stairs.
One firefighter was taken to the hospital with heat exhaustion and wheeled out of the apartment building on a stretcher. Others were treated for minor injuries.
"The heat was very challenging, with all our gear on," Batallion Chief Michael Brown said. "And just walking to the top of the building with the equipment, that's when our work starts."
The fire was brought to a third alarm just to get more support and give the firefighters a break.
"We can't operate for that long and when you do operate, you've got to come down and you've got to drink and cool off," Brown said.
Some residents were already awake when the fire ignited. They had a rough night sleeping in the heat, because part of the building was already without power.
"I seen my hallway all flooded with smoke," resident Charlin Ramos said. "So I called 911, and I started banging on everybody's doors so that they could come out. Then I got my family out and everybody else. Thank God everybody made it safe."
Authorities say that 25 people -- 22 adults and three children -- were left homeless by the fire. An MTA bus was being used as temporary shelter to help them escape the heat.