Runaway dog Echo, was stranded on the stretch between North Queensferry and Dalmeny for about two hours at peak time on Friday night.
The British Tranport Police and Scot Rail staff co-ordinated a mission to save the Romanian rescue dog and bring it back to safety.
Eyewitnesses reported seeing the terrified pet running back and forth, avoiding countless trains.
Train driver Ross Scott from South Queensferry was working the late shift and swooped in to save the dog from the busy line. Driving the 1912 service from Edinburgh Waverley to Kirkcaldy, he had been warned of the furry fugitive.
He explained: “I was working back shift on Friday and was notified about a disruption on the Forth Rail Bridge and had been told that for the past hour there had been a dog on the bridge.
“As I approached Dalmeny station the police had told me that the dog is still on the bridge. I proceeded with caution and saw Echo curled up in a ball by the track south of the first portal. I contacted the signaller who gave me permission to attempt to retrieve the dog. I jumped down and managed to get a hold of him and carried him back to the train.”
A southbound train with the dog’s owner aboard then stopped next to Ross’ train.
He added: “Someone shouted down that the owner was on board their train so my Network Rail colleague carried Echo over to the other train and reunited him with his owner.”