Police sealed off a rail bridge on the outskirts of Elgin tonight after reports of a young man in trouble.
Several police vehicles were called to the scene of the incident on the Pinefield Bridge on Reiket Lane around 9pm.
The incident came to an end shortly after 9.30pm when a police officer, who had acted as a negotiator, managed to lead the teenager to safety.
It is believed the young man had recently suffered a bereavement.
He was taken to a waiting ambulance where he was checked over by paramedics.
No train services were delayed as a result of the incident, as that area of the line is currently closed for on-going engineering works.