Company spokesman Ed Greenberg said there were no injuries and there was no leakage from the cars, which were left lying on their sides at the Alyth Yard.
The cars were carrying a diluting agent used in oil pipelines.
Greenberg said the north-bound train was moving at a slow speed when the cars left the tracks.
The company has launched an investigation to determine what happened.
Calgary Mayor Naheed Nenshi said there was briefly a small evacuation of the immediate area but everyone has since been allowed to return home.
He said Blackfoot Trail, a major commuter route, would be closed overnight but crews were working to ensure it could be reopened by morning.
Also on HuffPost