Several hours after the accident, flames and dark smoke could be seen billowing out of the train coaches, as protesters blocked firefighters from the station in Dhamara Ghat, a small town in Bihar state, officials said.
Dinesh Chandra Yadav, a local member of parliament, said the pilgrims were crossing the tracks in the packed, chaotic station when they were struck by the Rajya Rani Express train. Several other people were injured.
S.K. Bhardwaj, a police officer in Bihar, said 37 people were killed.
Railway official Arunendra Kumar said the train was not supposed to halt at Dhamara Ghat and had been given clearance to pass through the station. However, some pilgrims waited on the tracks thinking they could stop the train, he said.
The train stopped a few hundred meters (yards) beyond the spot where it hit the pilgrims. Angry mobs then pulled out the train driver and beat him. Yadav said the driver died, but Kumar said the driver was in hospital in critical condition.
The mob then got all the passengers out of the train and set some coaches on fire. Groups of young men also smashed the windows of two other trains that were in the station.
A crowd of around 5,000 people gathered near Dhamara Ghat station and were chasing away the district officials who tried to remove the bodies from the tracks. The crowds blocked the railway tracks and the few policemen posted at the station had fled, state officials said.
Prime Minister Manmohan Singh appealed for calm in the area so that relief and rescue operations could be carried out, a statement from his office said.
Junior railway minister Adhir Ranjan Chowdhury said the mob set fire to at least two coaches of the train, and protesters were preventing firefighters from reaching the accident site.
Police said the state government was sending additional forces to the area, but their movement was hampered because railway authorities had shut down train traffic on tracks leading to Dhamara Ghat, police officer Bhardwaj said.
Kumar Ashutosh, a passenger on the train, said that within a few seconds of hitting people on the track, the driver slammed the emergency brakes and the train ground to a halt.
"Soon, groups of people began running toward the engine. They asked us to get down from the train. Some of them pulled out the driver and his assistant and began beating them," said Ashutosh, who walked nine kilometers (six miles) from the accident site to the nearby Saharsa station.
District magistrate Syed Pervez Alam said the dismembered bodies of passengers who had been killed were lying on the track. The angry mob has chased away policemen and officials who tried to reach the station.
"I had woken up and was sitting near the window, when all this happened. There were crowds of people on the platform and some on the track. It all happened so fast," Ashutosh said.
He said that although the train had been given clearance to pass through Dhamara Ghat without stopping, the driver was partly to blame.
"The driver did not slow down when the train approached the station. He maintained the high speed at which the train was moving, so it was difficult for him to stop when he realized that there were people on the track," said Ashutosh, who was traveling in the first coach next to the engine.
Railway officials said a rescue train on its way to Dhamara Ghat had to be halted at Saharsa because the tracks were blocked. Dhamara Ghat is about 280 kilometers (175 miles) north of Patna, the state capital.
Monday was the last day of monthlong prayer ceremonies at the Katyayani temple near Dhamara Ghat, a popular Hindu pilgrimage site. The pilgrims were returning from offering morning prayers.
More than 18.5 million passengers travel every day on India's vast railway network of about 10,000 passenger trains.