Thirty years ago the town is said to have had little more than a chip shop and a couple of "down-at-heel" hotels.

It was a brief stop-off before rail passengers got back on the West Highland Line to Fort William or hopped onto a ferry, bound for the Hebrides.

Mallaig is now a busy and bustling port that boasts award-winning fine dining restaurants, upmarket hotels and other attractions. 

Much of the town's rise in fortunes is said to be due to the Jacobite steam train, immortalised in the Harry Potter movies weaving and puffing its way majestically around the Glenfinnan viaduct.

The Herald: The Jacobite train doubled as the Hogwarts Express in the Harry Potter movies Picture: Warner BrothersThe Jacobite train doubled as the Hogwarts Express in the Harry Potter movies Picture: Warner Brothers (Image: Warner Brothers)

Such is his tourist magnetism, that the Highland village might now be more famous for its connection to the boy wizard than Bonnie Prince Charlie, who raised the Royal standard there to mark the start of the fateful campaign to regain the British throne for a Stuart king.

Enjoy a year’s access to The Herald for £20

The Jacobite service brings an estimated £25 million annually to the UK economy, with its twice-daily service taking 750 tourists daily to Mallaig and Fort William in peak season.

However, the world-famous service is under threat. A requirement to fit Central Door Locking (CDL) to historic railway coaches could spell the end of the line for the Jacobite.

READ MORE: How Scotland's iconic Jacobite became a runaway success 

Since 2003, heritage steam trains have been allowed to run passenger services on the main line with an alternative locking system through two ten-year exemptions granted by rail regulators.

However, earlier this year, West Coast Railways (WCR) was told by the Office of Rail and Road (ORR) that the exemption was to be revoked.

WCR say the installation of new technology on its heritage carriages would cost £7m, making the sector unviable and wiping out profits for close to a decade.

The Herald: The Glenfinnan Viaduct is a top attraction in Scotland due to its fame through the Harry Potter

WCR has challenged this decision through the courts and a decision is expected in January.

"The Jacobite is our flagship - we aren't just going to roll over and give up," says James Shuttleworth, commercial manager for WCR.

"I've been involved in this since 1995 and when we started Mallaig had a chip shop and couple of down-at-heel hotels.

"It's now got some extremely good restaurants and other things. It punches way above.

READ MORE: Independent cinema in Scottish Highlands named best in the UK by London elite 

"It was the end of the [rail] line, the end of the road for the ferry terminal and of course the road went round the side of the village so it was bypassed.

"It isn't now. In high season, we are bringing 750 tourists a day into Mallaig on two services - it's a significant number of people."

Highland Councillor Angus MacDonald said the loss of the service would "decimate" Mallaig's tourist industry.

A spokesman for the ORR said the majority of charter heritage operators had either complied with the regulation by installing central door locking or have a plan in place to do so.

The Jacobite's operator says it has robust safety procedures in place to protect passengers with one steward per carriage in place to operate doors and monitor droplight windows and an additional guard.

Over time, safety issues have been raised by the ORR and this has led to further improvements including increasing the provision of stewards on services and signs above droplight windows.

READ MORE: 'Extremely rare' opportunity for trainee drivers on 'magical' rail line

The steam train's operators say the ORR is working hard to provide safer railways for passengers but say it is enforcing regulations that were intended for busy commuter services and not heritage, passenger-limited services.

"The system we have in place works and it is safe," says Mr Shuttleworth, who lives in Derbyshire. 

The steam train service was launched in 1984 under Scotrail and was then taken over by British Rail, known as the West Highland and then The Lochaber.

"I came up as a volunteer in 1994 for a weekend because I hadn't been before and you couldn't find anything out about it. It was dead on its feet," says Mr Shuttleworth.

"All the local businesses said, 'we need somebody' and they came to us and we said that we weren't very good at the marketing but we are good at the operating.

"We went in at the ground level and we had a lot of support and we worked bloody hard at it. It didn't just happen overnight.

"We took about 16,000 tourists in the first season. We are now taking 175,000." 

He worked with Warner Brothers to oversee the transformation of the train into the Hogwarts Express. "We've got a very good relationship with Warner," said Mr Shuttleworth.

"We market the association but we don't go over the top. It's others that have done that.

"The Harry Potter interest came long after we had finished filming. We did it out of season and we finished in 2011 when the last film was finished."

He says he does have some sympathy for Glenfinnan residents who now have to contend with a huge influx of tourists twice a day.

"When I first started, I was usually the only person on the hillside," he says.

"I used to take the odd photograph and there was no-one around. I find it ironic that the visitor centre in Glenfinnan markets the Harry Potter connection harder than it did Bonnie Prince Charlie.

"If the ORR comes down on us heavily, it's going to be difficult and we will have to make a decision on that.

"It's our intention that we keep running it but if we have to fit door locking, it's going to be an expensive business."

A spokesman for the ORR said: “As the rail regulator our role is to ensure that Britain's railways are run safely.

“There has been a regulation in place since 2005 which prohibits the operation on the main line of carriages with hinged doors for use by passengers.

“The majority of charter heritage operators have either complied with the regulation by installing central door locking or have a plan in place to do so. Services can operate with compliant carriages.”