It is thought the three-storey building at Bishop's Gate, Thorntonhall, was so badly damaged it may have to be demolished.
Scottish Fire and Rescue said the fire on Friday evening was originally tackled by eight firefighters inside the building.
However, they were withdrawn over fears the building might collapse.
Efforts to fight the fire continued externally using a specialist appliance.
The blaze was extinguished, but the roof of the building has gone and the third storey is completely destroyed.
Residents of Bishop's Gate were given teas and coffees at the nearby Thorntonhall Tennis Club.
A spokesman for South Lanarkshire Council praised the "community spirit" and said all of the residents had been given alternative accommodation by relatives.
About 20 residents had to be evacuated from a block of flats after a major fire in a South Lanarkshire village.