A train driver pulled his train to a halt before apprehending a man who was trespassing on the rails.
The driver, a special constable, had been told by Northern Rail colleagues that a man, who appeared to be under the influence of drugs and alcohol, was walking down the track towards Church and Oswaldtwistle from Accrington.
After contacting police he stopped his Blackpool North to York service and apprehended the 43-year-old man who was threatening to harm himself.
Trains passing through Church and Oswaldtwistle were delayed by around 30 minutes as police arrived to deal with the situation at around 4.20pm on Tuesday, August 23.
Lancashire Police and British Transport Police confirmed the trespasser was taken away and has since been detained under the Mental Health Act.
A Northern Rail spokesperson said: "At around 4.20pm on Tuesday one of our drivers reported a trespasser on the tracks at Church and Oswaldtwistle and alerted all oncoming trains.
"One of Northern's drivers, acting in his role as a special constable, detained the trespasser until the British Transport Police arrived to deal with the situation.
"We urge everyone to realise the dangers of trespassing on the railway, not only to them but to innocent train passengers and crew, and luckily on this occasion nobody was seriously hurt."
Network Rail said there was an average delay of seven minutes for about 20 trains because of the incident.