LUXEMBOURG (Reuters) - A long-running legal battle between global chocolate giants over the shape of KitKat finger wafers was sent back to the EU’s trademark office on Wednesday after judges dismissed appeals by both companies.

The ruling by the European Court of Justice means the EU Intellectual Property Office (EUIPO) must review a 2012 decision to uphold Swiss-based Nestle's NESN.S trademark on the shape of the four-finger chocolate-covered wafer biscuit over objections raised by Mondelez MDLZ.O of the United States.

The Luxembourg court found that Nestle had failed to show that consumers in enough EU countries recognized the shape as distinctive but also dismissed an appeal by Mondelez against some of the grounds for a lower EU court ruling in 2016 that had found the EUIPO was wrong to reject the U.S. firm’s complaint.

The outcome leaves open that the trademark agency could, while respecting the judges’ ruling, take account of other evidence -- such as new proof the shape is distinctive to people in more countries -- and might preserve protection for KitKat’s shape. The brand name “KitKat” is not at issue in the case.

Proceedings have been followed closely by trademark lawyers, who see implications for brands operating across the EU single market, where there are varying histories in national markets.

It has also at times featured in Britain’s Brexit debate, with some supporters of cutting ties with the EU suggesting that EU courts have failed to defend a much-loved British treat first marketed by Rowntree’s, which was bought by the Swiss in 1988.

In 2015, the Brexit-supporting Daily Express newspaper headlined a story on an earlier ruling: “End of the KitKat?”. It said an EU “diktat” might “spell the end of” the wafer bars as the “market could now be flooded with copycat confectionery”.

The case has also been mirrored by a dispute between the two multinationals in the British courts, where Nestle objected to a trademark for the purple color used by Cadbury, bought by the Americans in 2010, to wrap its Dairy Milk chocolate bars.