The workers had been investigating an ongoing fault with overhead line equipment just south of Penkridge railway station at 12.06am on July 11.
They were almost hit by the freight train but managed to move clear of the path of the train less than one second before it reached their position.
And another train was passing the track workers on an adjacent line as the freight train approached, the Rail Accident Investigation Branch said.
The near-miss has led to an investigation being launched by the Government agency to determine the sequence of events leading to the incident.
A spokesman said: "At around (12.06am) on July 11, 2022, two track workers were almost struck by a freight train travelling at 61 mph (98 km/h) just south of Penkridge station, Staffordshire.
"The track workers moved clear of the path of the train less than one second before it reached their position. Another train was passing the track workers on an adjacent line as the freight train approached them.
"At the time of the incident, the track workers involved were investigating an ongoing fault with the overhead line equipment which was preventing trains with electric traction from using this section of line, causing significant levels of disruption to train services in the area."
The investigation will include the actions of those involved, the arrangements to protect track workers from moving trains, the roles, responsibilities and working patterns of relevant staff, how the competence of staff was managed and any relevant underlying factors.