About 15 officers rushed to the old Paradykes Primary in Mayburn Walk, Loanhead, shortly after 9.30pm last night.
Flames were so fierce, firefighters were forced to tackle the inferno from outside though it was later confirmed no one was in the building.
“They fought the fire externally as the building was fully involved,” said a Scottish Fire and Rescue spokeswoman. “All persons were accounted for.”
Crews from Dalkeith, Liberton and Penicuik attended, using pumps and hoses to tackle the fire.
Nearby residents took to social media as towering flames lit up the night sky.
Alan Smith said: “Terrible fire at the former Paradykes nursery building.”
Wilma Ferguson said she was “gutted” at the blaze.
“Paradykes nursery is on fire, I know it was all getting knocked down but that & the school was a huge part of mine & my boys lives.”
Crews were still dampening down the charred shell of the school this morning.