A boy snuck out of his house at 4am to play on some nearby tracks just as a speeding train approached.
Quick-thinking cops were able to chase the six-year-old off the level crossing seconds before the train passed.
They had received a report and two officers rushed to the scene.
READ MORE: Rogue sheep sparks traffic chaos as cops praise ‘baa-rilliant’ public helpers
CCTV footage showed the child running up and down the tracks in the early hours of the morning.
When the barriers closed, the boy sat down on the train line and remained there for a short period of time.
A police car arrived and two officers jumped out to get him off the tracks as quickly as possible.
The boy stood up and ran away as the two cops gave chase.
A speeding locomotive whizzed past the level crossing moments later.
The cops were seen carrying the lad to the patrol car as the clip came to an end.
The lucky escape took place in Mikołów in southern Poland at about 4:30am, as reported by Need To Know.
The police shared the footage on social media on Monday (4 Aug).
They said the incident took place on the morning of 26 July.
Police spokesperson Izabela Kempka said: “After arriving at the scene, the officers looked for a child playing near the road.

“Arriving at a railway crossing with the barriers down and lights flashing, they noticed the boy crouching directly on the tracks.
“Moments later, a train passed through the level crossing.
“The child slipped out of the house while his parents were sleeping.”
Sergeant Dawid Furman and Senior Constable Patrycja Wolny took the boy to the police station and later contacted his parents.
The police advised citizens: “We urge everyone to keep an eye on their little ones, because even if you hide the keys and lock the door, children are resourceful enough to still be able to leave the house.
“Let’s remember to talk to our children about safety rules – even if we think they are too young for it.”
READ MORE: Cannabis stash worth £50,000 found in old village pub after tip off from suspicious locals