A group of railway workers had just three seconds to get away from a high speed train that was travelling towards them.
The workers, who were near Egmanton level crossing in Nottinghamshire, scrambled clear of the 125mph train with one second to spare.
The train driver spotted the workers in the distance and sounded a horn, but they did not respond. He then repeatedly sounded the horn.
Now a report has revealed shocking safety practices which almost ended in 'major tragedy'.
The Rail Accident Investigation Branch (RAIB) said the person in charge had them working under an 'unsafe and unofficial system of work'.
They said the person in charge - who was employed by Network Rail - shouted a warning to the others in order to maximise the working time of the group.
Instead, he should have used the Train Operated Warning System (TOWS) and moved the team, remaining in a safe place while the system was in place. But this broke down when the lookout and the person in charge became distracted and forgot about the TOWS warning.
None of the team involved - who were part of a group supplied to Network Rail by Vital Human Resources - challenged the unsafe system of work that was in place at the time of the terrifying near miss, which happened on October 5 2017.
The report found that even though some were uncomfortable with it, they feared they might lose the work as contractors if they challenged the person in charge.
Simon French, chief inspector of rail accidents, said: "In this investigation, RAIB found that the person in charge had adopted an unsafe method of working in an attempt to undertake additional unplanned work.
"Both the person in charge and team members became distracted, and the result was that three of them found themselves jumping clear of a train travelling at 125 miles per hour with just one second to spare.
"This came so close to being a major tragedy. We have seen this sort of unsafe behaviour before, where the wish to get the work done quickly overrides common sense and self-preservation."
Mr French added: "When we see narrowly avoided tragedies of this type, it is almost always the result of the adoption of an unsafe method of work and the absence of a challenge from others in the group.
"We are therefore recommending that Network Rail looks again at how it monitors and manages the safety leadership exercised by its staff, and how they interact with contractors."
A Network Rail spokesperson said: “Safety is our top priority and we take incidents such as the one at Egmanton extremely seriously and we have worked closely with the Rail Accident Investigation Branch on this report.
"We work hard to prevent incidents like this happening and we have already begun to implement the recommendations made.”