Emergency services were called to Dunkirk Mills on Thursday night following reports of a fire at a block of flats.
Gloucestershire Fire and Rescue Service tackled the rapidly developing blaze, which had spread to the fifth floor at Walkers Mill in Inchbrook near Nailsworth.
A total of 45 firefighters attended the incident, and 18 firefighters wore breathing apparatus to tackle the blaze inside the building.
The blaze was fought using three main jets and was contained to two flats.
There were no casualties and Gloucestershire Constabulary and South Western Ambulance Service were also in attendance.
The last fire engine left the scene at 1am.
Mark Bostock, group manager at Gloucestershire Fire and Rescue Service, said: “Crews found a rapidly developing fire on the 5th floor and worked hard from the outset. Although two flats were significantly damaged by the fire, the remaining apartments have been saved by the hard work of our crews to stop the fire spreading.
“Our crews did a brilliant job at tackling the blaze quickly and safely. At the moment the investigations into the cause of the fire are still ongoing.”
For more information on advice on how to stay safe in the home, please visit www.glosfire.gov.uk.