An internal rule which prohibits the visible wearing of any political, philosophical or religious sign does not constitute direct discrimination, judges concluded.
The European Court of Justice (ECJ) judgment was sparked by the case of a woman who was fired from her job as a receptionist at G4S in Belgium.
Samira Achbita was dismissed in June 2006 after insisting on wearing the Islamic headscarf at work.
She challenged her dismissal in the Belgian courts, which referred the case to the ECJ in relation to interpretation of an EU directive on equal treatment in employment and occupation.
The Court of Justice found 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.
A press summary setting out the ECJ's findings said: "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.
"It is not evident from the material in the file available to the court that that internal rule was applied differently to Ms Achbita as compared to other G4S employees.
"Accordingly, such an internal rule does not introduce a difference of treatment that is directly based on religion or belief, for the purposes of the directive."
The Luxembourg-based court found that the prohibition on wearing an Islamic headscarf, which "arises from an internal rule of a private undertaking prohibiting the visible wearing of any political, philosophical or religious sign in the workplace", does not constitute direct discrimination based on religion or belief within the meaning of the directive.
The summary added that such a ban may constitute "indirect discrimination" if it is established that the apparently neutral obligation it imposes results in people adhering to a particular religion or belief being put at a particular disadvantage.
However, such indirect discrimination may be "objectively justified by a legitimate aim", such as the pursuit by the employer, in its relations with its customers, of a policy of political, philosophical and religious neutrality, provided that the means of achieving that aim are appropriate and necessary.
These conditions should be checked by the Belgian court, the ECJ added.
Nick Elwell-Sutton, employment partner at law firm Clyde & Co, said: "The judgment demonstrates to employers how critical it is for a businesses to have a well-documented policy and to apply it consistently across the workforce."
In a judgment on another case, the court found that the willingness of an employer to take account of the wishes of a customer no longer to have its services provided by a worker wearing an Islamic headscarf cannot be considered a "genuine and determining" occupational requirement within the meaning of the directive.