An inspector from the Health & Safety Executive (HSE) was passing Clayton le Woods Primary School, near Chorley, on 31 January this year when he spotted four men working on the roof.
No scaffolding or other safety equipment had been installed, despite one of the men working at the edge of the roof next to a 15ft drop.
The inspector immediately served a prohibition notice ordering the men to come down from the roof until safety measures were put in place. HSE prosecuted Hall Isherwood Ltd, the company responsible for overseeing the work, for two breaches of the Work at Height Regulations 2005.
South Ribble Magistrates' Court in Leyland heard on Friday that the company had been hired to carry out work at the school on Back Lane in Clayton le Woods, which included painting work and replacing slates on one side of a sloping roof.
The only access to the roof was by using a ladder, which had not been secured to stop it slipping. Once the workers were on the roof, there were no guard rails or scaffolding in place to stop them from falling.
Hall Isherwood Ltd, of Wensley Road in Blackburn, was fined £750 and ordered to pay £1,581 in prosecution costs after admitting both safety offences.
Speaking after the hearing, HSE inspector Anthony Polec said: "This was a large project taking place over several days. Scaffolding or other safety equipment should therefore have been used to ensure the work could be carried out safely.
"As the principal contractor on the site, Hall Isherwood was responsible for making sure lives weren't put at risk. However, it allowed the workers to use an unstable ladder to reach the roof and there were no safety measures in place once they were on top of the building.
"Falls from height are responsible for several deaths on UK construction sites every year and it's only luck that no one was injured in this instance."