Plans for Flying Scotsman to visit Scotland are back on track after they were earlier cancelled at short notice by Network Rail because it could not be sure the world famous steam locomotive was suitable for the lines. The track operator said it had been unable to carry out safety assessments on all of the routes.

Branding the affair "a debacle", Scotland's Transport Minister Derek Mackay accused the rail body of "appalling incompetence" and became a figurehead for a lobbying campaign to restore some of the route.

He later tweeted: "Solved. Flying Scotsman will run on Borders and Fife. Questions remain on how it came to this, but thanks a solution was found."

Network Rail chief executive Mark Carne offered a "wholehearted and sincere apology" and said an investigation into Friday's cancellation will still take place.

Hundreds of rail enthusiasts planning to see the recently refurbished engine were left disappointed by the last minute cancellation which Network Rail said was necessary because it did not have the right data to "gauge" the engine - the process which checks to see if it fits within structures such as platforms and bridges on the line.

Hundreds of people across the UK have already turned out to catch a glimpse of the famous engine which was built in Doncaster, South Yorkshire, in 1923 and pulled the first train to break the 100mph barrier in 1934.

The National Railway Museum in York bought the locomotive for £2.3m in 2004 before work got under way on its decade-long restoration two years later.

After the track operator's U-turn, the locomotive will now be able to run on the Borders which reopened in September 2015. A planned trip across the Forth Bridge into Fife will also take place.

Carne said Network Rail's engineers and analysts had "worked hard to find a way to get the necessary safety checks and engineering assessments done."

"I wholeheartedly and sincerely apologise for the consternation caused by the premature announcement yesterday," he said. "Once the tours have been safely and successfully run, I will be instigating a full investigation into how this problem occurred on our railway in Scotland."