Thick smoke billowed from the roof of the building on North Fort Street, in Leith, where ten apartments were extensively damaged.
The residents of a neighbouring block of eight flats was also evacuated as a precaution at the height of the blaze.
Fire crews were called out to the five-storey building shortly after 6pm on Saturday.
A spokeswoman for Lothian and Borders Fire and Rescue Service said only the fourth and fifth floors were affected by the blaze.
The fire service said seven engines were in attendance when fire was at its height.
There were no casualties in the incident.