A 69-year-old woman and 57-year-old man were rescued from the blaze by firefighters and given oxygen on scene.
They were both taken to the Royal Infirmary of Edinburgh suffering from smoke inhalation.
A Labrador Collie cross also had to be given oxygen by firefighters as well as three further residents, one woman and two men, who were all treated on scene.
The fire started in one of the bedrooms of the three-storey block on Grierson Crescent in the Granton area of Edinburgh.
Fire crews were called to the flats just after 11pm on Tuesday .
The cause of the fire is thought to be electrical and residents of the flat were alerted to the flames by their smoke alarm.
A spokeswoman for Lothian and Borders Fire and Rescue Service said: “A working smoke alarm in the property alerted the occupiers to the fire giving them vital time to raise the alarm and escape.
“Although they suffered smoke inhalation the circumstances could have been much worse had they not had a smoke alarm. Neighbouring properties were affected by heavy smoke and firefighters gave residents fire safety advice and reassurance until they were able to make the building safe and ventilate the common areas.”