BRUSSELS (AP) — The European Union is closing a loophole that allows companies to shift some of their profits between different country divisions to avoid taxation.

European Union finance ministers in Luxembourg on Friday agreed on the reform after months of squabbling because some countries feared losing business from multinational firms.

The ministers say the legislation will ensure that corporations can't shift profits across borders of the EU's 28 nations to redefine their gains as tax-deductible loans to their subsidiaries.

Small EU countries specializing in attracting firms with low corporate taxation, like Luxembourg and Malta, had long opposed the legislation.

EU officials say that overall, tax fraud and firms' aggressive cross-border tax avoidance schemes cost the bloc's governments an estimated 1 trillion euros ($1.3 trillion) a year.