Adrian Bayne approached the distressed youngster after spotting signs that he might want to take his own life.
The 43-year-old, who had just finished work, persuaded the young man to hand over his mobile phone so he could call his family – and found the farewell messages.
Adrian, from Prestonpans, East Lothian, then alerted police and the family of the man.
The Virgin Trains driver had taken a Samaritans intervention training course after one of his friends took his own life three years previously.
It was the first time Adrian had used his training, and the incident, which happened during the summer, earned him a place among finalists for the Samaritans Life Saver Award at the Railstaff Awards in Coventry last week.
Adrian said: “The guy was sitting in an area of the station that people normally wouldn’t be sitting, in a distressed manner, with his phone in his hand.
“He said his mum was supposed to be picking him up in Berwick, but he was in Edinburgh at 10.40 at night.
“At that time of night there’s always drunk people and it’s about telling the difference between the drunks and people in trouble, and this guy was obviously in trouble.”
Adrian offered to phone his mother and saw messages on his mobile from people concerned about him.
Adrian added: “The messages he had sent were basically saying goodbye to them, without going into too much detail he was talking about ending his life.
“So I phoned British Transport Police and they sat with him for 20 minutes.
“Part of the training is that once you’ve passed them on to the police you distance yourself, but I know he was saved. I phoned his mum and she was in tears, but I told her he was safe.
“I had mixed feelings. It’s obviously emotional at the start, especially because of what happened with my friend. But afterwards I was feeling good because I managed to help save him.”
Adrian says he wants to promote the importance of suicide awareness, not only because it is close to his heart but also because of the relevance for train drivers. He is encouraging other rail workers to take up the training so that they can be in a position to intervene as he did.
He said: “As a train driver we’re at the forefront of suicides. I don’t think there’s enough understanding of the effect of suicides on train drivers. I’ve never had one myself but there was one on the tracks the other day and it’s horrible. But obviously there is also the impact on the victims’ families as well.
“It’s something that can be stopped. The training says that when the person is in that zone there’s a window of opportunity of 30 to 40 minutes in which you can save them. That’s what the training is about, trying to make the most of that opportunity.
“As well as the Samaritans training which I did after my friend died, I’m also a mental health champion at work. We’re trying to get more people to do the training because it is a big issue on the railways.”
Contact The Samaritans on 116 123 or email [email protected]