Confectionery giant Nestle has failed to convince European judges that it has the right to trademark the shape of its four-finger KitKat bar in the UK.

The European Court of Justice said that the company had to demonstrate the public relied on the shape alone to identify the snack.

The judges concluded this was difficult to prove if goods also showed a brand name such as KitKat.

Rival Cadbury has battled to prevent Nestle obtaining the trademark.

Both Nestle and Cadbury said they were "pleased" with the ruling.

The case will now return to the UK High Court for a final decision.

Nestle claimed that in the 80 years since the chocolate bar was introduced, the four fingers have become almost completely associated with KitKats.

In June, a senior European court lawyer, the advocate-general, disagreed saying such a trademark did not comply with European law.

Nestle has not sought to trademark the two-fingered bar.

Sally Britton, intellectual property lawyer at Mishcon de Reya, said that Nestle was likely to continue arguing its case, "even if, as now appears likely, the English court decides that the KitKat shape should not be registered as a trade mark".

She said Nestle had experience of trying to register difficult marks.

It took more than 40 years for it to register the slogan "Have a Break" as a trade mark, finally succeeding in 2006, she added.

Image caption Norway's "Kvikk Lunsj" looks similar to the KitKat and is available in some parts of the UK

Chocolate wars

Wednesday's ruling is the latest development in a more than 10-year legal battle between Nestle and Cadbury, which started when Cadbury tried to trademark the purple colour it uses on its Cadbury chocolate wrappers.

Nestle objected and finally had the original decision allowing Cadbury to trademark the colour overturned in 2013.

Now it would appear Cadbury, which is owned by US company Mondelez International, has scored a significant but not final victory in the continuing chocolate war.

It has always argued the shape alone was not distinctive enough for consumers to associate it with the rival snack.

A bar called the Kvikk Lunsj, meaning "quick lunch", launched in Norway in 1937 is available in some UK shops, and although less well known, looks similar to the four-finger KitKat.

A ruling in favour of Nestle would stop other confectionery producers making chocolate bars of the same shape or size.