The ruling was the first by the European Court of Justice on an issue that includes Islamic headscarves in the workplace.
Employers in Europe may ban staff from wearing visible religious symbols, the European Union's top court ruled on Tuesday in its first decision on the issue of women wearing hijab at work.
On the eve of a Dutch election in which Muslim immigration has been a key issue and a bellwether for attitudes to migration and refugee policies across Europe, the European Court of Justice (ECJ) gave a joint judgement in the cases of two women, who were dismissed for refusing to remove head scarves.
"An internal rule of an undertaking which prohibits the visible wearing of any political, philosophical or religious sign does not constitute direct discrimination," the court said in a statement.
"However, in the absence of such a rule, the willingness of an employer to take account of the wishes of a customer no longer to have the employer's services provided by a worker wearing an Islamic headscarf cannot be considered an occupational requirement that could rule out discrimination."
TRT World's Kevin Ozebek reports from Brussels.
The first case was referred to the ECJ by Belgium. Samira Achbita was fired from the Belgian branch of G4S, an outsourcing and security company, after three years at the firm when she started to wear a headscarf at work for religious reasons. She was fired in June 2006 for refusing to take off her scarf. The company said she broke rules prohibiting religious symbols.
In the second case, IT consultancy firm, Micropole, fired Asma Bougnaoui after a customer complained that she had embarrassed his staff when she wore a headscarf on a consulting assignment. Micropole told her before she took the job that wearing a headscarf might be a problem for some customers.
In Achbita's case, the ECJ ruled that companies should be able to ban the display of symbols associated with personal beliefs.
"The court of justice finds that G4S's internal rule refers to the wearing of visible signs of political, philosophical or religious beliefs and therefore covers any manifestation of such beliefs without distinction. The rule thus treats all employees to the undertaking in the same way, notably by requiring them, generally and without any differentiation, to dress neutrally."
In the Bougnaoui case, the court found that she had suffered discrimination. But it did not rule whether she had been sacked as the result of a company policy, saying this was a matter for the French courts to decide.
TRT World's Sara Firth explains details of the EU court's headscarf ban ruling.
"Backdoor to prejudice"
The Open Society Justice Initiative, a group backed by the philanthropist George Soros, said the ruling "weakens the guarantee of equality" offered by EU laws.
"In places where national law is weak, this ruling will exclude many Muslim women from the workplace," a policy officer for the Equality and Inclusion cluster of the Open Society Justice Initiative Maryam Hmadoun said.
Amnesty International welcomed the ruling on the French case that "employers are not at liberty to pander to the prejudices of their clients".
But, it said, bans on religious symbols to show neutrality opened "a backdoor to precisely such prejudice".
The president of the Conference of European Rabbis, Chief Rabbi Pinchas Goldschmidt, complained: "This decision sends a signal to all religious groups in Europe".
National court cases across Europe have included questions on the wearing of Christian crosses, Sikh turbans and Jewish skullcaps.