Each of the workers, who claimed they had suffered deliberate prejudice which had an impact on their careers and retirement benefits, was awarded between €150,000 and €230,000, said Abdelkader Bendali, a Moroccan teacher who helped them in their legal fight.
According to the ruling by an industrial court, which specializes in workplace conflicts, the SNCF was found guilty of "discrimination in the execution of work contracts" and "in the rights to retirement."
The Moroccan immigrants were hired as private contract workers in the 1970s and denied the status of "railway worker" which comes with several benefits in terms of job security, retirement and working hours.
That coveted status was reserved for European citizens and young recruits.
Even those who later received French nationality and were awarded the permanent contract complained their careers had been deliberately curtailed.
A total of 832 railway workers were involved in the group action and almost all were awarded damages. Many of them have waited a decade for the outcome and the ruling was met with an outpouring of emotion.
Ahmed Katim, who was hired as a contractor in 1972, burst into tears, describing the ruling as "restoring dignity to Moroccans, which is hugely satisfying."
Mohamed Ben Ali, 65, who is still working, said he finally feels he is "100 percent a railway worker. It is a big thing, they recognize the distinction that the SNCF made between us and the French."
Abdelhadi Fedfane, 66, who was hired as a contractor in 1974, retired in 2010 "broken from head to toe" due to decades toiling outside, on the tracks, repairing wagons.
"We trained the youngsters, but we remained mere assistants. It broke our morale," he said.
Fedfane said he was delighted with the ruling even if "it won't repair my health."
Lawyers for SNCF made no immediate comment on the result.
The mass of files meant each plaintiff would be individually informed of their result from October 23, and the rail company will have a month to appeal.
During the trial the SNCF's lawyer said the plaintiff's submission was "imprecise" and argued it was perfectly legal to distinguish between permanent hires and contract workers.