Employers can ban staff from wearing headscarves in certain cases, an EU court ruled on Thursday.
Two Muslim women working in Germany brought their cases to the European Court of Justice after they were banned from wearing their headscarves at work.
The court ruled that a ban on religious symbols such as headscarves "may be justified by the employer's need to present a neutral image towards customers or to prevent social disputes".
The employer must show, however, that it is not discriminating between different beliefs and religions in its policy.
The two women, a cashier in a chemist and a special needs carer, initially took their cases to the German courts, which referred them to the ECJ for an interpretation of EU law.
The woman working at the chemist had been employed there since 2002 and had initially not worn a headscarf, but wanted to begin wearing one in 2014.
However, her employer instructed her to come to work "without conspicuous, large-sized signs of any political, philosophical or religious beliefs", the ECJ said.
The other woman was employed in 2016 as a carer at a non-profit association and had initially worn a headscarf at work.
She went on parental leave, during which time the association issued a policy prohibiting the wearing of visible signs of political, ideological or religious conviction in the workplace for employees with customer contact.
After returning from parental leave, she refused to remove the headscarf, which resulted in several warnings and eventually led to her dismissal.
The ECJ said national courts must now examine in each individual case whether company rules are compatible with national laws on religious freedom and the need for a "policy of neutrality".
It said there must be "a genuine need on the part of the employer" for such a policy, which must not go against "national provisions on the protection of freedom of religion".