Italy and the European Union have finally reached a deal that will allow Europe's fourth-largest economy to avoid sanctions from Brussels over its government budget for next year, averting a potential crisis in the eurozone.

Brussels and Rome had been at loggerheads over the Italian government's plans to increase both the debt and the deficit in the country, pushing the deficit as high as 2.4% of gross domestic product over the coming years. Such proposals put Italy at risk of falling foul of EU limits on spending.

After weeks of wrangling, the two parties have agreed to allow Italy to run a budget deficit of 2.04% next year, higher than a previously mandated limit but well below the Italian government's initial proposal.

The agreement will provide the "basis for balanced budgetary and economic policies in Italy," Valdis Dombrovskis, the EU's most senior official dealing with the euro and financial systems, said, according to the Financial Times.

Italy, however, "urgently needs to restore confidence in its economy to ease financial conditions and support investment," he added, describing the solution as "not ideal."

The agreement means Italy will no longer be subject to the so-called Excessive Deficit Procedure, which has the power to fine countries within the eurozone that break the bloc's spending rules. Italy's entry into the EDP was set to be announced Wednesday.

Markets have reacted positively to the announcement, with Italy's benchmark FTSE MIB trading more than 1.7% higher on the day. It had climbed Wednesday morning as rumors surfaced that a deal would be struck. The euro was also higher against the dollar on the day, trading at €1.1402, a gain of 0.35%.