A New Jersey father and son escaped with their lives after they drove onto train tracks and a NJ Transit train rammed into their car Thursday morning, officials and witnesses said.

Jonathan Lin, 55, crashed through the warning gate and onto the tracks around 7:30 a.m near the New Bridge Landing station in River Edge, New Jersey, according to NJ Transit officials and video from the scene.

Lin’s black Honda — which was also carrying his 16-year-old son — appeared to come to a stop about a second before the Hoboken-bound train slammed into it as it pulled into the stop, surveillance footage showed.

“I heard loud impact — ‘Bang!'” said George Aydin, 38, who was working at a nearby BP gas station when the collision occurred. “I look and see the train going by and the car’s tires I see on the other side.”

The pair were rushed to Hackensack University Medical Center for treatment. Lin, of Oradell, New Jersey, suffered five broken ribs and his son had cuts to his head and some bruises, NJ Transit spokeswoman Lisa Torbic said.

The train was going roughly 40 miles per hour — about 10 miles per hour below the speed limit — when it collided with Lin’s car, railroad spokeswoman Nancy Snyder added.

“It felt like we ran over something,” Matthew Marmolejos, a commuter on the train, told northjersey.com. “The train immediately came to a screeching halt and I saw the conductor looked distraught, and that’s when I realized we may have hit something.”

Officials are still investigating why Lin broke through the safety gate and how fast his car was moving, Snyder said.

In addition to his injuries, Lin was slapped with summonses for careless driving and disregarding a railroad crossing, Torbic said.

The train had left Spring Valley earlier in the morning and had 400 commuters and crew aboard — none of whom were injured in the smash-up.

The crash suspended rail service on the Pascack Valley line for about two hours, according to NJ Transit’s Twitter posts.