FLYING Scotsman should be back under steam later this year as one of the most complex restorations of a steam locomotive ever undertaken enters its final stages.

The £4 million overhaul of the famous engine began after it was bought by the National Railway Museum, in York, in 2004.

Now, it is being fitted with the equipment needed for the locomotive to operate on the main line with a view to trials beginning before the end of the year.

The work to fit the Train Monitoring Recorder and the Train Protection & Warning System is taking place at the specialist engineering firm Riley & Son Ltd, in Bury, Greater Manchester.

Riley's co-director Colin Green said: "We have come through all the critical milestones for a locomotive restoration and although there is a lot of work still to get through and parts to fit, there is nothing significant standing in the way of Scotsman coming back to steam."

The company was appointed in October 2013 to complete the high-profile restoration project to bring the locomotive, which was built in Doncaster in 1923, back to Britain's tracks.

Bob Gwynne, curator of collections and research at the NRM, said Flying Scotsman's inaugural main line run from London to York is scheduled to be the opening event for the museum's February Flying Scotsman Season.

He said: "The fitting of the equipment for the mainline really makes its return a reality.

"We still anticipate that the restoration work to return Flying Scotsman to steam will be completed in late 2015. This will be followed by a full programme of running in tests on heritage lines.

"Once it has built up sufficient mileage on the mainline - 1,000 miles under its belt - and it's resplendent in its new BR green livery it will be ready for its long-anticipated inaugural run between London and York - a triumphant return home at long last."

A commercial partnership agreement has been reached under which Riley & Son Ltd will manage the operation of the locomotive for the first two years of its new life.

This will include a programme of on-going maintenance using Riley's experience of keeping steam locomotives on the tracks and in-depth knowledge of Flying Scotsman, as well as helping to resolve any issues that may arise during its return to mainline steam.

The locomotive, designed by Sir Nigel Gresley, was originally built in Doncaster for the London and North Eastern Railway (LNER) and emerged from the works on February 24, 1923.

A year later it was renumbered and given the name Flying Scotsman - named after the London to Edinburgh rail service which started daily at 10am - when it appeared at the British Empire Exhibition.

This event made it famous. In 1928 it hauled the first ever non-stop London to Edinburgh service, reducing the journey time to eight hours. And, in 1934, Flying Scotsman was clocked at 100mph - the first locomotive to have reached that speed.

In 1948, with the nationalisation of the railways, it was renumbered again and painted Brunswick Green. The museum has decided to stick with the British Railways Green 60103 livery for the restoration.

The museum bought Flying Scotsman in 2004 for £2.3 million - a figure partly reached with a £1.8 million grant from the National Heritage Memorial Fund.