A lesson in rescue techniques was the last thing pupils at a primary school expected.
But fire crews were forced to stage one after a tawny owl became stuck in the rafters of the school gym minutes after a high-diving display.
The seven-year-old bird of prey had become spooked as his handler tried to usher him into a holding cafe and flew high into the roof – catching a lanyard on a sprinkler.
Trapped high in the roof space, firefighters were scrambled to Loanhead Primary School and deployed a huge ladder to reach the stricken owl.
But after a snared rope was untangled, the tame bird calmly hopped on to the gloved hand of the firefighter who carefully climbed down the rungs, hanging on with only one arm.
Once back on terra firma after around 45 minutes, the bird was treated to his favourite dish – a baby chick.
Red-faced handler Kylie McSeveney, from Falconry Scotland, said the bird – called Boomah – had returned to normal.
“It was just a total mishap,” the 29-year-old said. “I wasn’t worried, just embarrassed.
“It wasn’t that he was not coming down, he was just physically stuck.
“He was trying to pull at the equipment but he was quite calm about it.”
The trainer, who has helped prepare birds of prey since she was seven, said the display had been “going well” before Boomah shot off into the rafters.
“Boomah was hand-reared by myself from an early age,” she said.
“He’s the cuddliest owl, so he was just there for the kids to touch. He wasn’t meant to be flying. “
Boomah was one of three tawny owls brought to the school to allow small groups of P1 and P2 pupils experience the majestic predators at first hand.
Nursery children were also given the chance to interact with the birds. A barn owl and a little owl had performed feats of aerial acrobatics but friendly Boomah – whose name is Arabic for owl – was meant to remain grounded.
Diane Donnelly, the headteacher of Loanhead Primary, suggested the school was renamed Hogwarts – in a nod to Harry Potter’s owl, Hedwig.
“The owl got a wee bit panicky when the fireman came up to free him, but he was absolutely fine – and the fireman was fine, too,” she said.
School janitor Eddie Phillips, 51, managed to capture the spectacle unfolding on his mobile phone.
He said: “It was quite dramatic.
“The lady tried to put the bird into the box at the end of the day – once the kids had left – but it got spooked and flew into the rafters.
“But the fire crews came to the rescue. The fire brigade were brilliant, really professional.”
A spokeswoman for the Scottish Fire and Rescue Service said: “Fire crews attended Loanhead Primary School to assist with an owl trapped on the gym roof after receiving a call at 3.30pm on Monday.
“One fire engine was sent from Dalkeith and the incident was closed at 4pm.”