First came the crash and the sparks. Then darkness and screams.

Passengers aboard the A train that derailed Tuesday morning recounted how it suddenly veered off the tracks in Harlem near the West 125th Street station, ripped a chunk out of a concrete wall and sparked a small track fire.

“I was in the second car from the end. It was a smooth ride, then the train felt jerky,” recalled Kelly Kopp, 48, of Washington Heights. “Then it gets severe and I saw an explosion.”

When the train stopped in the tunnel, plunging the riders into darkness, many screamed in fear.

“It was scary. I literally thought I was going to die on a subway,” Kopp said. “I tried to open the door, and it was locked. We tried to pry the door open and I thought, ‘We are trapped and locked in.’ ”

It took 20 minutes for MTA crews to evacuate riders from the disabled train and escort them along the tracks to safety, according to passengers.

advertisement | advertise on newsday

Photos and videos from riders posted on Twitter showed blown-out subway windows and riders navigating through train cars with the flashlights on their cellphones.

Many other riders took matters into their own hands.

About 500 commuters left their stalled trains nearby before first responders could get to them, officials said. About 300 firefighters and police officers were deployed between the 135th Street and Cathedral Parkway-110th Street stations to bring above ground those who risked their lives by stepping onto the tracks.

Elizabeth Tritsch of West Harlem was on her way to a medical appointment when the she and her 11-year-old daughter were stuck on a southbound D train for more than two hours because of the derailment.

Eventually, MTA workers used ladders to lead her, her daughter and others out of the back of the train to the nearby 135th Street station, Tritsch said.

“People in my car were listening to music; some were dancing. It was a little less hectic than others,” Tritsch said. “I practice meditation, so I was sending positive energy to my train.”

The incident was just the latest in a series of high-profile MTA service disruptions. Earlier this month, a steamy, stalled F train in Manhattan stranded riders underground as they pried at doors just to get some fresh air.

“I have to give myself 30 to 45 minutes when I take the train now. The delays are endless,” Tritsch said. “It’s extremely upsetting.”

With Adeja Creater, Alison Fox and Matthew Chayes