The Jacobite was used as the Hogwarts Express in the film adaptations of author JK Rowling’s Harry Potter stories.

ScotRail services and other trains also travel across the viaduct.

The Glenfinnan area, near Fort William, gets more than 600,000 visitors a year, according to the National Trust for Scotland.

Network Rail Scotland said large crowds of people often gathered near the viaduct to see the Jacobite steam train.

Route crime manager Neil Cook said there were dedicated viewing spots at the site.

He said: “The Jacobite steam train’s journey over Glenfinnan Viaduct is a magical sight but it’s not worth risking your life for.

“Too often, we receive reports of dangerous behaviour, with people climbing fences, standing on the railway, or walking along the track to try to get closer.”

Cook added: “Trespassing on the railway is illegal and puts lives at serious risk.

“Trains can come from either direction, are quieter than people expect, and can’t stop quickly.”