Workplace bans on the wearing of "any political, philosophical or religious sign" such as headscarves need not constitute direct discrimination, Europe's top court has ruled.
But the ban must be based on internal company rules requiring all employees to "dress neutrally", said the European Court of Justice (ECJ).
It cannot be based on the wishes of a customer, it added.
This is the court's first ruling on the wearing of headscarves at work.
The ECJ's ruling was prompted by the case of a receptionist fired for wearing a headscarf to work at the security company G4S in Belgium.
The issues of Muslim dress and the integration of immigrant communities have featured prominently in debates in several European countries in recent years. Austria and the German state of Bavaria have recently announced bans on full-face veils in public spaces.
Rights group Amnesty International said Tuesday's ECJ rulings were "disappointing" and "opened a backdoor to... prejudice".
The ECJ was ruling on the case of Samira Achbita, fired in June 2006 when, after three years of employment, she began wearing a headscarf to work.
She claimed she was being directly discriminated against on the grounds of her religion and Belgium's court of cassation referred the case to the EU's top court for clarification.
At the time of Ms Achbita's hiring, an "unwritten rule" had been in operation banning overt religious symbols, and the company subsequently went on to include this explicitly in its workplace regulations, the court explained.
G4S's rules prohibited "any manifestation of such beliefs without distinction", and were therefore not directly discriminatory, the court said.
It said "an employer's desire to project an image of neutrality towards both its public and private sector customers is legitimate" - but national courts had to make sure this policy of neutrality was applied equally to all employees.
In practice, such a policy must therefore also ban other religious insignia such as crucifixes, skullcaps and turbans, the court confirmed to the BBC.