Commuters faced disruption to train services as police dealt with a man on the Stockport viaduct.
British Transport Police said its officers were called to reports of a man on the track.
Some lines between Manchester Piccadilly and Stockport were blocked and subject to delays.
It took emergency services almost 24 hours to bring the man to safety.
Network Rail said the line was cleared at 04:20 BST and British Transport Police Greater Manchester later tweeted that the “trespass incident” at Stockport was “resolved”.
“We would like to thank the public for their support and understanding as we tried to bring the man to safety as quickly as we could,” Network Rail added.
The incident led to significant disruption with some trains diverted.