The Flying Scotsman's visit north of the border will not go ahead as planned after a last-minute decision by Network Rail.

The track operator said it had not been able to carry out assessment work on some lines in time for the tour, which has been in the planning for more than a year.

The Flying Scotsman will operate between York and Edinburgh Waverley on Saturday as scheduled, but a vintage diesel engine is expected to take over for Sunday's trip, which was to see it run on the new Borders Railway to Tweedbank and across the Forth Bridge.

The decision will disappoint hundreds of rail enthusiasts expected to turn out to see the recently refurbished steam engine.

Excursion operators Steam Dreams said: "Network Rail has known about these trips for months and they have left this gauging until the last minute.

"It means there is absolutely no time to plan anything else for the locomotive so we can give passengers in Scotland a trip behind this icon."

Built in Doncaster, South Yorkshire, in 1923, the Flying Scotsman 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.

Network Rail was forced to pay out almost £60,000 in compensation when dozens of train services were delayed by people encroaching on the track during the refurbished train's inaugural run from London to York on February 2 this year.

A spokesman for the operator said: "The routes the Scotsman had planned to cover this weekend are new ones for the locomotive and have to be individually assessed by our engineers in advance.

"Unfortunately we have been unable to carry out the work in time and cannot allow the engine to run when we are unsure if the unique design of the Flying Scotsman is compatible with the current railway infrastructure across the Fife and Borders routes.

"We understand the disappointment this will cause all those who had been looking forward to the iconic engine returning to these parts of Scotland and a full investigation will be undertaken into why these issues were not identified sooner."

A spokeswoman for the National Railway Museum said: "We can confirm there is nothing mechanically wrong with the engine which makes its triumphant return to Scotland post-restoration on Saturday May 14 with the York-Edinburgh leg of the Cathedral's Express service.

"We share the disappointment of the people of Scotland who were hoping to catch a glimpse of Flying Scotsman on its travels through Fife and the Borders."

The Flying Scotsman will be displayed at the Bo'ness and Kinneil Railway on Monday as planned, with an extra day on Sunday.

Transport minister Derek Mackay issued a strongly-worded statement in which he blasted the "farcical" situation and said "mishandling" of it would be fully investigated.

Mr Mackay said: "This announcement is hugely disappointing and represents appalling incompetence by Network Rail GB.

"I will be ensuring this mishandling of an application is fully investigated. I believe the rail alliance in Scotland is working well, and this debacle at Network Rail GB HQ is further reason to devolve more functions to Scotland where we take seriously the economic benefits of rail in a way that seems to have escaped Network Rail GB HQ. I will be raising this at the most senior levels.

"The enthusiasm with which the return of the Flying Scotsman was greeted by thousands of people, not only in Scotland but around the UK, was evident in the huge amount of interest there was in seeing this iconic piece of history returning to Scotland.

"This is not only a disappointment for the residents of Fife, Midlothian and the Borders, who will be hit economically by the cancellation of this long awaited and landmark event, but who have also been let down by the farcical nature of how it was allowed to happen."