By Idrees Bakhtiar
BBC news, Karachi
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.
Madan's family say he suffers from mental illness
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.
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.