The authorities in the Pakistani city of Karachi have accused an "insane person" of stealing a train engine and then driving it through two stations.
They say that the actions of the man very nearly caused a major accident, as he was only yards away from colliding with a crowded passenger train.
Police have now remanded the man for three days in custody.
He has been identified as Madan, a resident of Hyderabad, a city about 160km (99 miles) east of Karachi.
The railway engine was stolen from a marshalling yard near Karachi after its driver and fireman left it to have tea, officials say.
We don't know as yet what his motive was for this attack. But he apparently knows how to drive a railway engine and had planned it
Karachi police spokesman Irshad Baig
They say that the accused man, Madan, drove the engine 30km (20 miles) towards Karachi and did not stop at two stations in between - prompting fears of a major terrorist incident.
A passenger train, plying the same railway track, was stopped at the main Karachi cantonment railway station to avoid a major accident.
The Divisional Superintendent of Karachi, Mir Mohammed Khaskheli, said that the stolen engine was then diverted to a loop line where engineers were able to bring it to a halt.
Madan was immediately arrested by police.
"God helped us avert a major human disaster," police spokesman Irshad Baig told the Reuters news agency.
Police say that that the accused man is over 50 years old, and had "responded incoherently" during questioning.
Police have been given custody of Madan for three days pending further investigations.
They say that it appears he wanted to ram the stolen engine into the passenger train.
Madan's wife, Jabli, and his son, Ramesh, told newsmen in Hyderabad that he was admitted to a mental asylum three months ago but had managed to abscond.
They said that they came to know of his whereabouts when they saw Madan's pictures on a local TV channel on Wednesday.
Police officials say they while they are confident he is insane, they first have to discount all possibility of him being a terrorist.
And we thought they were criminals...u think its in the genes instead?? Impulse sudden desire to crash passenger vehicles....
Maybe the Islamic world needs to pop some pills from our Shrinks. U know we said mass terror killing is madness--we maybe more accurate than we realize!!