MADRID — A security camera has captured the moment when a Spanish train veers off the track and crashes into a wall at high speed.

The footage posted Thursday on YouTube shows the train rounding a bend, making a turn to the left underneath a road overpass.

The train's first carriage behind the locomotive appears to come off the tracks first, slamming the tail of the locomotive into a concrete wall.

All the carriages can be seen starting to come off the tracks as the locomotive hurtles toward the camera position.

The security camera footage appears to stop at the moment that the engine crashes into it.