A sheriff’s deputy pulled a driver from his car moments before it was struck by a train in California.

Dramatic video posted to YouTube shows a sheriff’s deputy pulling a man from his sedan, which was on the Caltrain tracks.

Moments later, a train barreled through the station, colliding with the car.

Taco Bell Worker Writes 'Pig' on Cop's Order

Caltrain praised the sheriff's deputies on scene for their heroism in a tweet posted after the incident.

Authorities say the car’s driver appeared to be under the influence.

Watch footage of the rescue below, via YouTube.

Watch Heart-Stopping Rescue of Commuter Who Fell on Subway Tracks

WATCH: Good Samaritans Pull Man in Wheelchair From D.C. Metro Tracks