EU companies can ban headscarves as long as it is a general prohibition that does not discriminate against employees, Europe's top court said on Thursday, the latest ruling on an issue that has divided Europe for years.

The case concerned a Muslim woman who was told she could not wear a headscarf when she applied to do a six-week work traineeship at a Belgian company.

The firm said it has a neutrality rule, meaning no head covering is allowed on its premises, whether a cap, beanie or scarf. The woman took her grievance to a Belgian court, which subsequently sought advice from the Court of Justice of the European Union (CJEU).

The Luxembourg-based CJEU said there should not be any direct discrimination in such a ban.

"The internal rule of an undertaking prohibiting the visible wearing of religious, philosophical or spiritual signs does not constitute direct discrimination if it is applied to all workers in a general and undifferentiated way," judges said.

The CJEU last year said that EU companies could ban employees from wearing a headscarf under certain conditions if they needed to do so to project an image of neutrality to customers.

In Germany, headscarf bans for women at work have been contentious for years, mostly with regard to aspiring teachers at state schools and trainee judges.

France, home to Europe's largest Muslim minority, prohibited the wearing of Islamic headscarves in state schools in 2004.

A woman walks past a mannequin wearing an hijab headscarf at a market in the Brussels district of Molenbeek
A woman walks past a mannequin wearing a hijab headscarf at a market in the Brussels district of Molenbeek, Belgium, August 14, 2016. Reuters