Nine coaches of a New Delhi-bound train derailed early Sunday in India, killing seven and injuring 29, officials said.

The majority of the passengers were asleep when the train jumped the tracks.

Shortly after the derailment, hundreds of local residents rushed to help rescuers and authorities who were trying to get people to safety amid the overturned train cars and twisted metal.

PLANE MAKES EMERGENCY LANDING ON MINNESOTA INTERSTATE EXIT RAMP

Indian Railways official Rajesh Dutt Bajpai said that by noon Sunday, the rescue work was over, and two of the injured were in critical condition, the Associated Press reported.

The cause of the accident is being investigated. The Press Trust of India news agency said a rail fracture appeared to have caused the derailment about 20 miles north of Patna, the Bihar state capital.

India's vast railway system is the world's third largest but lacks modern signaling and communication systems. Most accidents are blamed on poor maintenance, outdated equipment and human error.

In 2016, 127 people were killed after 14 coaches derailed in Uttar Pradesh state, in one of India's worst train accidents.

The Associated Press contributed to this report.