The court said that companies were able to ban "the visible wearing of any political, philosophical or religious sign".
The ruling made clear that if the ban was only applied to Muslim members of staff it could still constitute discrimination.
The judgement was sparked by the cases of two women - one living in France and one in Belgium - who were dismissed from work after refusing to remove their headscarves.
Companies would need to already have a policy in place prohibiting the wearing of religious symbols and would not be able to ban staff from wearing headscarves on the "wishes of a customer".
The court statement read: "An internal rule of an undertaking which prohibits the visible wearing of any political, philosophical or religious sign does not constitute direct discrimination.
"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."
Samira Achbita, a receptionist for security company G4S, was dismissed after insisting on wearing her Islamic headscarf to work.
The company told her there was an unwritten rule prohibiting employees from wearing visible signs of religion in the workplace.
Ms Achbita challenged the decision in the Belgian courts, claiming she was being discriminated against at work on grounds of her religion.
In the second case, design engineer Asma Bougnaoui was fired from consultancy company Micropole, after a customer complained about her wearing of the Islamic headscarf.
Ms Bougnaoui - who had refused to stop wearing her veil - had taken her case to the Court of Cassation in France.
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."