Like Mr. Lakhal, Ms. Emtir, who is 49, was also fired. Both sought to get their jobs back, but the court did not order them to be reinstated.

The French labor court judges wrote that the measures taken so far by H. Reinier “to protect the four employees were nonexistent” and that the preventive measures were “wholly insufficient.” Further, the court said, when the women reported the sexual harassment, they were “systematically sanctioned for it.”

The company declined for several years even to move the man who was accused of the harassment to a different location. Ms. Monteil, the company’s lawyer, said that from H. Reinier’s point of view, it had to “put everyone on an equal footing.”

That decision meant that the women had to see their harasser every day when they went to work, fearing always that he would touch them or follow them into a train bathroom, shut the door and attack them sexually.

Maud Beckers, the women’s lawyer, said before the decision was issued that if the company was found to be responsible for the environment of sexual harassment and threats against employees who complained, the company should “clean house” and fire those who were accused as well as the directors who allowed the pernicious behavior.

As of Friday, the man named as responsible for the harassment in the court decision, Mbarek Bachchikh, was still working for the company, according to Ms. Monteil, the company’s lawyer.

SNCF, France’s national railroad, continued to use the company for cleaning services even after questions about sexual harassment and criminal activities were raised. A company communications official said on Friday that SNCF “welcomed the decision.”