Fifteen fire engines and around 100 firefighters were sent to the scene in West Hampstead, north west London, just after 1am.
London Fire Brigade said the fire was believed to have started in a flat on the fourth floor of the five-floor building, although the cause is not clear.
Firefighters were still trying to get the flames under control, the brigade said just before 4am.
Photos on social media showed flames and thick smoke coming from the building, with the top floor appearing to have been taken over by the fire.
Station manager Clainton Murray said: "The fire is also affecting the roof and in the early stages was very visible for miles around.
"Due to concerns that the roof could collapse inward firefighters evacuated residents from the top floor.
"In addition fire crews assisted two people from the first floor and a number of other residents self evacuated from lower floors.
"Around 50 residents are using a local public house as a rest centre.
"The London Ambulance Service have confirmed that no one was taken to hospital as a result of this incident.
"Firefighters have carried out salvage operations to save where possible residents' possessions from water damage."
The block is understood to be Welbeck Mansions which, according to a local estate agent, was built in 1897.