The UK gives up 10.5bn euros (£7bn) of its rebate, some 20%, while the budget grows to 862.4bn euros, helping to fund the development of new member states.
In return, France has agreed to a budget review in 2008-2009, which could lead to cuts in farm subsidies.
UK Prime Minister Tony Blair said the deal allowed Europe to move forward, avoiding a serious crisis.
Once again, the crisis has been resolved... Europe is now marching forward again
French President Jacques Chirac
Referring to budget commitments to new, mainly east European member states, he told reporters: "If we believe in enlargement, we had to do this deal now."
Mr Blair later told the BBC that had Britain walked away from the compromise deal it "would have wrecked" London's relations with the new EU members and the new German government.
German role
The 2007-13 budget figure agreed represents 1.045% percent of EU output, up from 1.03% in an earlier proposal but still well below the 1.24% sought by the European Commission.
EU BUDGET 2007-13 (EUROS) Overall spending: 862.36bn UK rebate down 10.5bn from a total of 50-55bn Aid to EU newcomers: 157bn (7bn more than the UK at first proposed) Farm and rural development aid: 292bn Justice and interior affairs: 10.2 bn Foreign and humanitarian aid: 50bn Administrative costs: 50.3bn
In quotes: EU leaders on deal Key points of the deal
Polish Prime Minister Kazimierz Marcinkiewicz, whose country will get 4bn euros more aid than the UK had at first proposed, punched the air and shouted "Yes! Yes!" when the deal was done.
French President Jacques Chirac, long at odds with the British leader over budget, praised Mr Blair's movement on the UK budget rebate.
By accepting the need to "deeply transform" the rebate, he said, Tony Blair had made a "legitimate but politically difficult" gesture.
Though France has agreed to a "full and wide-ranging" mid-term review of the budget, it has the option of vetoing any proposed changes.
German Chancellor Angela Merkel, said to have played an important part in securing the final compromise, greeted the deal as "a good accord for the future of Europe".
Germany, the UK and France, along with all the other wealthier EU countries, are having to increase their contributions to help pay for the 2004 round of enlargement.
The EU leaders also made a qualified commitment to further enlargement, by granting Macedonia the status of EU candidate country.
However, they said further steps, such as the opening of membership talks, would depend on the outcome of a "debate on the enlargement strategy".
Globalisation
BBC Europe Editor Mark Mardell says the deal allows the EU to end the year if not exactly on a high then on at least a success, when yet another crisis was seriously on the cards.
The EU was left in disarray last June when the rejection of the EU constitution in France and the Netherlands was followed by an acrimonious collapse of talks on the budget.
If there had not been a deal at this summit, new member states would not have had time to plan how to use the development aid they become eligible for in 2007, and some of it would have remained beyond their reach.
Tony Blair's grand project was to give Europe a modern budget, refocusing the spending of the European Union so it can face up to the challenges of globalisation rather than subsidising farmers, says Mark Mardell.
He has achieved nothing like that, our correspondent says, not even the certainty that a review will apply to this budget round. But he has ensured that the EU will return to the subject.
The leaders of the European Union have  struck a deal on the 2007-2013 budget. Negotiations were characterized by host country's Prime Minister Tony Blair as "extraordinarily complicated".

The biggest issues were different views between France, the UK and rest of the EU. UK wanted to keep it's high membership discount, negotiated before economic growth made it one of the richest members, while other members wanted it to participate with relatively equal net payment. France's primary issue was maintaining farming subsidies. Rest of the Europe was mostly interested in modernizing European economy by decreasing both UK's discounts and France's subsidies. Germany appeared as a pulling force between France and UK to secure the deal.

France continues to receive it's highly criticized subsidies. The UK gave up 10.5 billion euros in exchange for a review of farm subsidies in 2008-2009, but the net membership discount will actually increase. Small member states such as Sweden increased their role as largest net payers in relative to output.

Key features in the reached deal:
* Total budget will be 862.36 billion euros, equaling to 1.045% of the EU's total GDP
* Development aid will be 157 billion euros
* Farm budget will be 293 billion euros

Most see the resulted budget as a poor comproromise, but necessarily for the state of union and financial planning in the new member states.