Emergency services were called to Cairneyhill Primary School near Dunfermline just after 1pm on Friday.
A blaze had broken out in building, with police urging people to stay away and keep nearby windows closed.
Staff and pupils were moved to a nearby church and were all said to be safe and well.
More than 30 firefighters have been tackling the blaze on Northbank Road.
A Scottish Fire and Rescue Service spokesman said: “Operations Control mobilised a total of seven appliances to the scene after the alarm was raised at 1.03pm on Friday.
“Firefighters wearing breathing apparatus are using high powered hoses to tackle the flames.”