Crews were called to the fire in the stairwell of the block in Cupar, Fife, shortly before 9.30pm on Saturday.
Five fire engines from the Cupar, Auchermuchty, Newburgh and Glenrothes stations were involved in the operation to deal with the blaze on the second floor of the four storey property.
They had to use a thermal image camera to help them work in the smoke-logged stairwell.
The Scottish Fire and Rescue Service said nine residents were led to safety from the building. Four dogs were also rescued.
One adult and one child received precautionary checks from paramedics at the scene.
A fire service spokesman said: “Fires within the common areas within a block of flats are a serious risk to those people living in them as they have no way to escape their homes and the smoke poses a real and terrifying risk of death. It is vital people keep these areas clear of all combustible storage or rubbish at all times.
“Praise must be given to the control room who kept the two separate residents on the phone and advised them of how to keep themselves safe, as well as the operational firefighters who attended this incident and got the residents out of their homes safely. Thanks to their professionalism and skill our community did not wake up to a tragedy this morning.”
The fire service and police will now investigate the cause of the blaze.