Apple has been told it will not have to pay Ireland €13bn (£11.6bn) in back taxes after winning an appeal at the European Union’s second highest court.

It follows a record ruling by the European Commission against the US tech giant in 2016.

The EU’s General Court said it had annulled that decision because the Commission had not proven Apple had broken competition rules.

It is a blow for the EU which wants to crack down on alleged tax avoidance.

“This case was not about how much tax we pay, but where we are required to pay it,” Apple said in a statement. “We’re proud to be the largest taxpayer in the world as we know the important role tax payments play in society.”

The European Commission brought the action after claiming the Irish government had allowed Apple to attribute nearly all its EU earnings to an Irish head office that existed only on paper.

It claimed this had allowed the tech giant to avoid paying €13bn of tax on EU revenues and given it an unfair advantage over competitors based in Ireland.

However, the Irish government argued that Apple should not have to repay the taxes, deeming that its loss was worth it to make the country an attractive home for large companies.

Ireland – which has one of the lowest corporate tax rates in the EU – is Apple’s base for Europe, the Middle East and Africa.

The ruling could spell bad news for the EU efforts to crack down on other cases of alleged corporate tax avoidance.

European Competition Commissioner Margrethe Vestager has spent much of her time in office campaigning against tax schemes she argued were anti-competitive.

However, last year she lost a case against Starbucks having alleged it owed taxes of €30m in the Netherlands. Rulings over Ikea and Nike’s tax arrangements in that country are also due soon.