The European Court of Justice (ECJ) said it does not constitute "direct discrimination" if a firm has an internal rule banning the wearing of "any political, philosophical or religious sign."
The Luxembourg-based court was considering the case of a Muslim woman fired by the security company G4S in Belgium after she insisted on wearing a headscarf.
Rights group Amnesty International said the ECJ action was "disappointing" and would only encourage discrimination.
"By ruling that company policies can prohibit religious symbols on the grounds of neutrality, they have opened a back door to precisely such prejudice," Amnesty said in a statement.
The wearing of religious symbols, and especially Islamic symbols such as the headscarf, has become a hot button issue with the rise of nationalist and sometimes overtly anti-Muslim parties across Europe.
Some countries such as Austria are mulling a complete ban on the full-face veil in public while in France last year local authorities barred women wearing the burkini, the full-body swimsuit, fining those who did.
Manfred Weber, head of the centre-right European People's Party, the biggest in the European Parliament, welcomed the ECJ finding as a victory for European values.
"Important ruling by the European Court of Justice: employers have the right to ban the Islamic veil at work. European values must apply in public life," Weber said in a tweet.
Treat all employees equally
The ECJ was ruling on a case dating to 2003 when Samira Achbita, a Muslim, was employed as a receptionist by G4S security services in Belgium.
At the time, the company had an "unwritten rule" that employees should not wear any political, religious or philosophical symbols at work, the ECJ said.
In 2006, Achbita told G4S she wanted to wear the Islamic headscarf at work but was told this would not be allowed.
Subsequently, the company introduced a formal ban. Achbita was dismissed and she went to court claiming discrimination.
The ECJ said European Union law does bar discrimination on religious grounds, but G4S's actions were based on treating all employees the same, meaning no one person was singled out for application of the ban.
"The rule thus treats all employees of the undertaking in the same way, notably by requiring them, generally and without any differentiation, to dress neutrally," the ECJ said.
"Accordingly, such an internal rule does not introduce a difference of treatment that is directly based on religion or belief," it said.
Customers cannot demand ban
However in a related case in France, the ECJ ruled that a customer could not demand that a company employee not wear the Islamic headscarf when conducting business with them on its behalf.
Design engineer Asma Bougnaoui was employed full-time by Micropole, a private company, in 2008, having been told that wearing the headscarf might cause problems with clients.
Following a customer complaint, Micropole asked Bougnaoui not to wear the headscarf on the grounds employees should be dressed neutrally.
She was subsequently dismissed and went to court claiming discrimination.
The ECJ said the case turned on whether there was an internal company rule in place applicable to all, as in the G4S instance, or whether the client's demand meant Bougnaoui was treated differently.
The ECJ concluded that Bougnaoui had indeed been treated differently and so the client's demand that she not wear a headscarf "cannot be considered a genuine and determining occupational requirement."