A train carrying 150 passengers was "seconds away" from crashing into a huge pile of debris, a union said.
An estimated 200 tonnes of rubble fell on to the line when a wall collapsed just outside Liverpool Lime Street station at 17:45 GMT on Tuesday.
Northern confirmed the driver of its Manchester Airport to Liverpool service hit the emergency brake after a red signal was triggered.
"It was seconds from disaster," said RMT regional organiser John Tilley.
"If it had hit the debris, then it would have derailed and there would have been fatalities.
"The only saving grace would have been that it was [only] travelling at 50mph.
"The debris coming down triggered the sensors [on the overhead lines] which thought that a train was on the line so the signal went red.
"Thankfully the train was just the right side of the signal otherwise it would have been a different story."
The 16:40 Northern service from Manchester Airport had to be evacuated, as did another Northern train from Wigan which was behind it.
A Virgin Trains service going to London Euston, which had just left Liverpool just after 18:00, also had to be halted.
A Northern spokesman said: "We are aware of two of our trains being caught up in the wall collapse.
"It just shows the red signal system works."
Network Rail said it was aware that trains had to be evacuated.
A spokesman said the company expects services in and out of the station to resume by 9 March.
He added that the work being carried out was a "temporary solution" and the track would have to be closed again at a later date to allow for a permanent fix.