Firecrews were called to the Canton-Galva Middle School at about 2:30 this morning for a fire.
The fire was reported to 911 by personnel aboard a passing train.
Fire officials believe a lightning strike from this morning's storm started the fire in the school's gym.
The fire was confined to the gym, and no one was injured, said Richard Baldwin, Galva Fire Department captain.
The McPherson Fire Department ladder was brought in to help gain access to the roof of the building so the fire could be fought from inside and above the building, Baldwin said. Crews from McPherson EMS also were on standby to assist firefighters.
No adjacent structures were threatened by the fire.
Crews were on scene until about 7:45 this morning.
School district personnel are now working with insurance investigators to determine the extent of the damage.
A dollar estimate has not yet been set for the damage.