A mob has beaten to death the driver of a train which ploughed into a group Hindu pilgrims when it crashed in eastern India.

A crowd said to number 5,000 gathered at Dharmara Ghat, a small town in Bihar state, after the accident in which 37 people were killed.

They attacked the driver, set fire to train coaches and smashed windows in other trains.

Dinesh Yaday, a local MP, said the pilgrims had been crossing the tracks in the busy station when they were hit by the train. Four children were among the victims, AFP reported.

The train stopped a few hundred metres from the crash and the mob pulled out the driver and his assistant and attacked them. The driver was taken to hospital in a critical condition but died from his injuries.

Kumar Ashutosh, a passenger, said the driver had slammed on the emergency brake seconds after hitting the pilgrims.

"Soon, groups of people began running toward the engine," he said. "They asked us to get down from the train. Some of them pulled out the driver and his assistant and began beating them."

SK Bharadwaj, a director general of police, saod: "Dozens of people have been injured. We do not have exact figures of those injured because they were taken away to various hospitals.

India train crash
Of the 37 Hindu pilgrims killed, four were children (Reuters) Reuters

"One of the drivers of the train who was beaten up by the agitators has died. The other driver is struggling for his life in the hospital."

Ashutosh said the driver had not slowed down as he approached the station.

"He maintained the high speed at which the train was moving, so it was difficult for him to stop when he realised that there were people on the track," he said.

The mob prevented the removal of bodies and prevented firefighters from reaching the site. District magistrate Syed Alam said dismembered bodies were still scattered around the scene.

Railway chief Arun Malik said staff fled the scene, "fearing attacks".

The prime minister, Manmohan Singh, appealed for calm to allow the relief operation to proceed. He expressed his "deep sorrow and shock" at the loss of lives.

The crash took place on the last day of the prayer ceremonies that take place at the Katyayani temple near Dhamara Ghat, a popular place of pilgrimage for Hindus. Those killed had been returning from offering morning prayers.