It was supposed to be a 18-minute ride to New York’s Pennsylvania Station after a night out in Newark, but not long after the New Jersey Transit train carrying John Foley and 1,100 other passengers entered a Hudson River tunnel, the lights flickered and it felt like the train might fly off the tracks.

“There were electrical explosions and sparks. People braced themselves because it felt like the train was freewheeling through the tunnel,” Mr. Foley, 40, of Manhattan, said on Saturday.

Transit officials said overhead electrical wiring dislodged around 11:30 p.m. on Friday, causing a piece of a metal bracket, connecting the train to the overhead power line, to puncture a passenger car of the Northeast Corridor train that Mr. Foley was in. About three to four feet of metal protruded into the car.

A few minutes later, a North Jersey Coast Line train with 500 passengers traveling from Penn Station to New Jersey struck a metal object hanging in overhead wiring as it exited the tunnel.