West Yorkshire Fire Service said half of Freeston Academy in Normanton, near Wakefield was ablaze at one point, leaving the building badly damaged.
More than 50 firefighters attended after the alarm was raised at 09:10 BST. The blaze was brought under control by about 12:00.
The fire service said there were no injuries and students were unaffected.
Local residents were advised to keep windows closed and stay inside at the height of the fire.
Ian Bitcon, area manager for the fire service, said the blaze was in the roof of the school which was "difficult to deal with due to access".
He said: "We've been very fortunate in that the school's unoccupied and there's been a very good water supply.
"We appear to pretty much have it cracked now."
A caller to Radio Leeds said: "I was on my way home when I saw this massive smoke and flames.
"They turned us all away and stopped us all going up the street.
"There's loads of kids here waiting for their GCSE results and they're all coming away in tears."
Students at the school were later directed to the sports hall to collect their exam results.
A woman whose daughter had been to collect her exam results at the school said: "It's been a crazy day".
She told BBC Radio Leeds: "It's been an emotional rollercoaster. First, getting up and waiting to come in and pick up the results.
"But then to hear the school was on fire. It's just been an utter drama."
In a statement, the school said: "Our main priority was the safety of our staff, students and contractors working on site, and to ensure that our year 11 students were able to collect their GCSE results.
"Following advice from the fire service, all students were able to collect their GCSE results from outside the sports hall.
"All staff on the site were accounted for and no one was hurt in the fire."
A large fire broke out a school as students gathered to collect their GCSE results.