When European leaders emerged bleary-eyed early on Saturday morning to proclaim a deal on a new EU budget for 2007-2013, a wave of relief swept through Brussels.
Two days of intense negotiations and horse-trading between member states finally delivered an agreement that will provide €862.4 billion to finance the EU.
Deciding the financial perspectives was clearly important for new member states, which need to plan their future spending. But for the European project a deal provided a much-needed boost following the rejection of the EU constitution by French and Dutch voters, renewed fears over enlargement and divisions over tackling economic problems.
"This is an agreement that allows Europe to move forward," said British prime minister Tony Blair to journalists shortly after 3am on Saturday after chairing the talks as current EU president.
Meanwhile, German chancellor Angela Merkel, who played a key role in the talks, declared: "The big cloud has been lifted from Europe."
In the run-up to the talks most leaders agreed failure to find a deal would have prompted a new crisis. Some analysts even said that a repeat of the acrimony at the European Council in June could spark an unravelling of the bloc, which has struggled since enlargement.
But despite strong criticism of the British handling of the budget in the run-up to the summit, the talks were tough but calm. There was also praise for Mr Blair when he agreed to politically difficult concessions on the rebate while receiving vague promises on future reform of the common agricultural policies from 2013 onwards.
Mr Blair's decision to give up €10.5 billion of the British rebate - a financial mechanism agreed in 1984 to compensate Britain for its small agriculture sector - over the next seven years was the key to breaking the deadlock. It generated some of the extra cash needed to meet concerns expressed by the new member states, and principally Poland, that the offer did not give them enough funds or solidarity.
The new budget will provide €157 billion in economic development aid for the poorer eastern European countries that joined the EU last year. This is less cash than offered in previous budget talks in June, but was made more palatable by a relaxation of the rules that states must follow to draw down funding. For example, in the next budget cycle EU funding can be used to build social housing and the deadline for the completion of projects will be extended from two to three years.
Greece and Portugal will also benefit from the rule changes, which are intended to overcome some of the problems that new member states will encounter in spending EU funds.
In the early hours of Saturday morning a series of new sweeteners was offered to many member states to move them towards accepting a deal. Spain secured €2 billion in structural funding, Italy got an extra €1.9 billion while Ireland won an extra €250 million in rural development funds when compared with a previous British budget proposal tabled shortly before the two-day summit started.
Mr Blair's offer on Britain's rebate helped to generate the extra cash and a proposal from German chancellor Angela Merkel to boost the overall size of the EU budget to €862.4 billion, or 1.045 per cent of gross national income, was also critical.
This made an extra €13 billion available when compared with the British proposal and brought it close to the Luxembourg package offered last June.
Ms Merkel played a pivotal role in the talks, acting as a go-between with Mr Blair and Jacques Chirac, and cajoling Poland to accept the final offer. Austrian chancellor Wolfgang Schuessel said she was "extraordinarily important" in the talks while Romanian president Traian Basescu said she "brokered the deal from start to finish".
Her performance, which comes just a month after taking over as German leader, is already leading political analysts to speculate that she could transform EU politics in coming years.
The size of the budget, which at 1.045 per cent of GNI is still significantly below the 1.24 per cent of GNI level asked for by the commission, was probably the best possible compromise in the circumstances.
However, it is unlikely to satisfy the European parliament, whose president Josep Borrell has already threatened to veto a poor deal. In practice, the parliament is unlikely to spark a new EU crisis just when the bloc seems to be on the road to recovery.
With its budget in place the EU will now move forward to grapple with other key challenges, principally reviewing its policy on further enlargement and the future of the EU constitution.