European Union leaders have finally clinched an unprecedented 1.82 trillion euro (£1.64 trillion) budget and coronavirus recovery fund.

The leaders finalised the agreement in Brussels in the early hours of Tuesday morning, finding unity after four days and nights of fighting and wrangling over money and power in one of the EU’s longest ever summits.

To confront the biggest recession in its history, officials said the EU had a consensus on a 750 billion euro (£677 billion) coronavirus fund to be sent as loans and grants to the countries hit hardest by the virus.

That comes on top of the seven-year one trillion euro (£900 billion) EU budget. At first the grants were to total 500 billion euro (£451 billion), but the figure was lowered to 390 billion euro (£352 billion).

German chancellor Angela Merkel said: “Extraordinary events, and this is the pandemic that has reached us all, also require extraordinary new methods.”

Belgian prime minister Sophie Wilmes said: “Never before did the EU invest in the future like this.”

“It is a historic day for Europe,” added French president Emmanuel Macron, who earlier reflected on some “extremely tense moments” during the marathon summit.

Just shy of being the longest EU summit in history, the 27 leaders huddled back in the main room of the Europa centre and bumped elbows and made jokes before giving the package the final approval.

“Deal!” wrote summit host Charles Michel on Twitter.

Belgium Europe Summit
French President Emmanuel Macron speaks with German Chancellor Angela Merkel as the summit finished up in the early hours of Tuesday (John Thys/Pool/AP)

What was planned as a two-day summit scheduled to end on Saturday was forced into two extra days by deep ideological differences among the leaders.

But overall, spirits were high early Tuesday since the talks hit rock bottom on Sunday night.

The coronavirus has sent the EU into a tailspin, killing around 135,000 of its citizens and plunging its economy into an estimated contraction of 8.3% this year.

Spanish prime minister Pedro Sanchez insisted the adoption of an ambitious plan was required as the health crisis continued to threaten the continent.

With Mr Macron and Mrs Merkel negotiating as the closest of partners, the traditionally powerful Franco-German alliance could not get the quarrelling nations in line for long.

Belgium Europe Summit
French President Emmanuel Macron and German Chancellor Angela Merkel towards the end of the meeting (John Thys/Pool/AP)

“The consequences will be historic,” Mr Macron said.

“We have created a possibility of taking up loans together, of setting up a recovery fund in the spirit of solidarity.”

He said this sense of sharing debt that would have been unthinkable not so long ago.

The French leader added: “When Germany and France stand together, they can’t do everything. But if they don’t stand together, nothing is possible.”

And he challenged anyone in the world who had criticised the days of infighting to think of a comparable joint endeavour.

“There are 27 of us around the table and we managed to come up with a joint budget. What other political space in the world is capable of that? None other,” Mr Macron said.

Mrs Merkel said: “We have laid the financial foundations for the EU for the next seven years and came up with a response to this, arguably biggest crisis of the European Union.”

The leaders mulled a proposal from the five wealthy northern nations – the Netherlands, Austria, Finland, Sweden and Denmark – that suggested a coronavirus recovery fund with 350 billion euro of grants and the same amount in loans. The five nations, nicknamed “the frugals”, had long opposed any grants at all, while the EU executive had proposed 500 billion euro.

The latest compromise proposal stands at 390 billion euros in grants.

“There is no such thing as perfection, but we have managed to make progress,” Mr Macron said.

All nations agree in principle they need to band together but the five richer countries in the north want strict controls on spending. Struggling southern nations like Spain and Italy say those conditions should be kept to a minimum.

The five have been pushing for labour market and pension reforms to be linked to EU handouts, and for a “brake” enabling EU nations to monitor and, if necessary, halt projects that are being paid for by the recovery fund.

The summit at the Europa Centre revealed how the nations’ narrow self-interests trumped the common good for all to stand together and face a common adversary.

Rarely had a summit been as ill-tempered as this one, and it was the longest since a five-day meeting in France in 2000, when safeguarding national interests in institutional reforms proved a stumbling block.

However, considering every EU leader had the right of veto on the whole package, the joint commitment to invest and spend such funds can be seen as a success.

“We all can take a hit,” Dutch prime minister Mark Rutte said. “After all, there are presidents among us.”

Despite bruising confrontations with Mrs Merkel, Mr Macron and his Italian counterpart, Giuseppe Conte, Mr Rutte maintained that “we have very good, warm relations”.