Companies in the European Union can ban employees from wearing a headscarf under certain conditions, if they need to do so to project an image of neutrality to customers, the EU’s top court said on Thursday.

The Luxembourg-based EU Court of Justice (CJEU) was ruling on cases brought by two Muslim women in Germany who were suspended from their jobs for wearing a headscarf.

The issue of the hijab, the traditional headscarf worn around the head and shoulders, has been divisive across Europe for years, underlining sharp differences over integrating Muslims.

In the cases brought to court, a special-needs carer at a childcare centre in Hamburg run by a charitable association and a cashier at the Mueller drugstore chain did not wear headscarves when they started their jobs, but decided to do so years later after returning from parental leave.

They were told this was not allowed, and at different points were suspended, told to come to work without it or put on a different job, court documents showed.

The court had to decide whether headscarf bans at work represented a violation of the freedom of religion or were allowed as part of the freedom to conduct a business and the wish to project an image of neutrality to customers.

Its response was that such bans were possible if justified by an employer’s need to present a neutral image.

“A prohibition on wearing any visible form of expression of political, philosophical or religious beliefs in the workplace may be justified by the employer’s need to present a neutral image towards customers or to prevent social disputes,” the court said.

That justification must correspond to a genuine need on the part of the employer, it said.

In the case of the care centre employee, the court said the rule at issue appeared to have been applied in a general and undifferentiated way, as the employer also required an employee wearing a religious cross to remove that sign.

In both cases, it will now be up to national courts to have the final say on whether there was any discrimination.