The LMS Royal Scot Class 6115 Scots Guardsman, which was built in Glasgow in 1927, was spotted as it travelled through Edinburgh on Sunday afternoon.
Mark Ballard, a Portobello local, was in his garden when he heard a whistle from the vintage train.
He quickly jumped on his bike, and managed to intercept it at a bridge as it passed through the town.
Mr Ballard shared a video of the steam train with other locals on Facebook, and wrote: “Not bad for a 95 year-old locomotive!”
The train was named the Scots Guardsman in 1928 after the Scots Guards.
In 1936, it played a starring role in the film Night Mail, a documentary charting a night mail train’s journey from London to Scotland.
While the Scots Guardsman was withdrawn from duty in the 1960s, it has since been restored and has made several journeys to stations across the UK.