Residents in buildings overlooking the tracks stared in disbelief at the scene unfolding below.

Michael Keaveney, 22, a security worker who lives in an apartment above the tracks, was awakened by the tumult. When he looked out his window, he said, “I thought I was still dreaming.”

When the train came to rest, passengers battered windows until they broke. Other riders were trapped inside for long minutes before emergency workers arrived, according to Kevin Farrell, 28, a hospital administrator who watched from his apartment. Seven minutes and two seconds after the first calls went out, emergency workers arrived, slightly delayed by the train’s imprecise location, a marshy area just north of Spuyten Duyvil Creek station, said Jay Jonas, deputy chief of Division 7, which was in command early in the operation. Diesel fuel glugged out into the dirt.

Firefighters quickly stabilized the cars strewed across the marsh grass and sedge. Jacks and air bags were deployed to prevent them from shifting and causing more injuries. Firefighters propped ladders on the carriages and scrambled up to reach windows and doors. Underneath one car was a passenger who had been killed.

More than 150 firefighters and emergency medical technicians swarmed over the scene, cutting some passengers free from the metal and glass, some walking from car to car, performing first aid on the injured.

Stunned passengers who had been extricated stood or sat in grass spangled with broken glass. A woman sat with her leg hanging at an unnatural angle.