The east coast main line was closed between Dundee and Carnoustie on Monday after an engineering train derailed.
Crews faced a "complex" task in rerailing the wagons, which were carrying lengthy interconnected rails, before repairing the tracks.
Network Rail said repairs were completed overnight, with the line reopened for normal working.
Commuters faced three days of cancellations and replacement services while the work was carried out.
Railway services through Dundee have been restored after a derailed train was cleared from the tracks.