Several Ettrickhaugh Road residents reported the blaze, saying they heard a loud bang.
The fire was in the former Philiphaugh Mill at the end of the road, and the first firefighters on the scene found the building ablaze.
Extra crews were summoned, from Dalkeith and Lauder, and at its height, 20 firefighters were tackling the flames.
As is normal in buildings of that age, asbestos in the roof exacerbated the problems.
Once the fire was extinguished, the job of dampening down the hotspots began, and the last crew left the scene at 9.30am yesterday.
A spokesperson for the Lothian and Borders Fire and Rescue Service told us: “We were called by a number of residents to an incident in an unused building in Ettrickhaugh Road, Selkirk, at around 9.24pm.
“On arrival, fire crews found the single-storey building, which was attached to other buildings, on fire.
“Extra assistance was called for and at its height, there were 20 firefighters on the scene.
“They stayed overnight to dampen down hotspots, and handed the building back to its owner at 9.30am.”