German Chancellor Angela Merkel hailed a "good compromise" with Poland over the voting system in the proposed treaty, the issue which had prompted Poland's populist leaders to threaten to block a deal. Merkel said the agreement would make a bloc which has grown from 15 member states to 27 since 2004 better able to act.
The new treaty will replace the Union's failed constitution, which was torpedoed after voters in France and the Netherlands rejected it in 2005.
"I was sure that if we had not achieved this today we would have ended up in a rather disastrous situation as many would have thought they had been pushed too far," said Merkel, whose country holds the EU's rotating presidency till the end of the month.
"We have managed to organize things so that no one can go home and feel they have been put in the corner," she said.
Frustrated by stonewalling on the part of Poland's leaders, Merkel threatened to move ahead on a new treaty with or without their blessing. The move spurred a revolt by Warsaw's friends but also triggered a flurry of mediation that ultimately convinced Poland to compromise.
The agreement means the full introduction of decision-making rules Poland had vehemently opposed will be postponed from 2009 until 2017. Britain is allowed a exemption from a binding set of human rights provisions other states signed up to.
Polish President Lech Kaczynski thanked France and Britain for their "solidarity" in helping to broker a deal.
British Prime Minister Tony Blair, in his final summit before leaving office next week, and newly elected French President Nicolas Sarkozy, had both engaged in attempts in the early hours of Saturday to persuade the Polish president and his twin brother, Prime Minister Jaroslaw Kaczynski, to drop their opposition.
The Kaczynskis had shocked European diplomats ahead of the summit by evoking their country's mass destruction at the hands of the Nazis in World War Two as an argument for it to get its way on the voting issue.
Spelling out the compromise, Merkel said the double majority voting system -- which Poland strongly opposed because it fears it will give big countries too much decision-making power -- would not be introduced until 2014 and would then be phased in over the next three years.
The chancellor said the compromise on the voting mechanism was "what Poland desired."
Sarkozy acknowledged the talks had come close to failure, but hailed the deal as "very good news for Europe." In a reference to Poland, he said: "It was not possible to ignore the biggest country in eastern Europe."
Prime Minister Tony Blair ended his swansong appearance on the international stage on a high note. His last EU stand was a triumphant one -- he stands down as prime minister next week -- secured all the key points without which he said he would not do a deal.
Blair said the accord was a "chance to move on" after the "bind" which the European Union had got itself into with the doomed constitutional treaty.
"The most important thing is that it allows us to move on to things that are ultimately far more important," he told reporters after the deal was clinched. "It gives us a chance to concentrate on the issues to do with the economy, organized crime, terrorism, immigration, defense, climate change, the environment, energy, the problems that really concern the citizens of Europe."
Blair largely succeeded in sticking to the four "red line" conditions he set for agreement on the new treaty -- that Britain would not cede control over foreign policy, its judicial and police system, tax and social security rules, and an EU charter of fundamental rights.
"I am sorry that Mr. Blair is going; he has always been a man who sought compromise in Europe," said Sarkozy.
Danish Prime Minister Anders Fogh Rasmussen paid a warm tribute, saying Blair "has contributed in a very valuable way to European cooperation," adding: "He's really a pro-European."
Chancellor Merkel said that the late finish to the negotiations meant "I was only able to utter a few warm words and express thanks to him."
Merkel said the agreement reached at the summit meant there was a "good chance" that a new treaty could go into force in 2009 when elections to the European Parliament take place.