The fire started around 1:30 a.m. at 1 Dahlgren Place, a duplex with two families living side by side, in the Bay Ridge section.
The flames broke out on the second floor and quickly spread.
At least two firefighters suffered minor injuries.
A freelance photographer who lives behind the building first pounded on neighbors' doors to alert them to leave their homes, then shot video of the fire.
The FDNY scrambled 33 units to the scene and kept the flames from spreading to other houses.
None of the residents of the homes were injured.