In its first decision on the topic of women wearing Islamic headscarves at work, the EJC ruled the garments could be banned, but only as part of a general policy barring all religious and political symbols.
The court said the ban must be based on internal company rules which state that all staff must "dress neutrally”.
The court also ruled that customers cannot demand workers remove headscarves if the company has no policy barring religious symbols.
“An internal rule of an undertaking which prohibits the visible wearing of any political, philosophical or religious sign does not constitute direct discrimination,” the ECJ said.
"The willingness of an employer to take account of the wishes of a customer no longer to have the services of that employer provided by a worker wearing an Islamic headscarf cannot be considered a genuine and determining occupational requirement.”
The ECJ's ruling was driven by the case of a receptionist fired for wearing a headscarf to work at the security company G4S in Belgium.
The receptionist 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.
When the receptionist was hired, an "unwritten rule" had been in operation banning overt religious symbols.
The company subsequently went on to include this explicitly in its workplace regulations, the court explained.
The ruling has come on the eve of Dutch elections, where Muslim immigration is a prominent issue.
In France, François Fillon, the presidential candidate who has taken a hard-line position on Islam, welcomed the ruling.
However, John Dalhuisen, director of Amnesty International's Europe and Central Asia program, said the ECJ's decision gave "greater leeway to employers to discriminate against women - and men - on the grounds of religious belief".
"The court did say that employers are not at liberty to pander to the prejudices of their clients,” he said.
“But by ruling that company policies can prohibit religious symbols on the grounds of neutrality, they have opened a backdoor to precisely such prejudice."
Employers will be allowed to ban workers from wearing headscarves, the European Court of Justice (ECJ) has ruled.