European Union leaders clinched agreement on Saturday on a mandate to overhaul the 27-nation bloc after persuading Poland to end a stand-off that nearly torpedoed a marathon summit.

The leaders agreed to negotiate a reform treaty by the end of this year, to be ratified by mid-2009, replacing the EU constitution rejected in 2005 by French and Dutch voters.

The 4:30 a.m. (0230 GMT) deal could relaunch the political integration of Europe after two years of gloom and introspection since referendums sank the constitution, dramatizing public disaffection with a project seen as remote and bureaucratic.

Provided it is ratified this time, the treaty should give Europe stronger leadership, a streamlined decision-making process, a bigger voice on the world stage and more say for the European and national parliaments.

If we had not achieved this today, we would have ended up in a rather disastrous situation because many would have felt they were pushed too far, German Chancellor Angela Merkel told a news conference after brokering the deal.

The deal opened the way for further enlargement of the Union, she said, which would be impossible without reformed institutions. Portuguese Prime Minister Jose Socrates, who takes over the EU chair in July, said he hoped to have the treaty agreed as early as October.

We have avoided a crisis, European Commission President Jose Manuel Barroso was quoted as saying in an interview to appear on Sunday in German newspaper Bild am Sonntag.

Uncertainty about our future treaty has cast a shadow of doubt over our ability to act. Now those doubts have been removed.

Leaders of several countries convinced Polish President Lech Kaczynski to back down after weeks of resistance and accept a compromise on voting rights in exchange for a long delay in their introduction.

After today, Poland is capable of much better cooperation with France, Britain and also Germany, because we experienced solidarity, Kaczynski told reporters.

He was unapologetic over comments that Poland deserved compensation for its suffering in World War Two. This offended many European leaders and privately infuriated Merkel.

History is history. It is fact that had there not been the war, Poland would not have 38 million people, but many more, Kaczynski said.

Merkel struggled to break Polish opposition to the treaty which it complained would cut Warsaw's voting power and give more say to big countries, especially Germany.

She eventually threatened to launch treaty negotiations without Warsaw's assent, prompting a final dash for compromise.

DELAY

Poland settled for a deal that put off full application of the new decision-making procedure until 2017.

Warsaw was also offered pledges of solidarity by the rest of the bloc in the event of future energy crises, a big concern of Poland which is heavily dependent on imports from giant gas and oil exporter Russia, its neighbor and former communist master.

The treaty will preserve key features of the constitution such as the creation of a long-term president of the Union and a foreign policy chief with increased powers.

The constitutional treaty was an easily understandable treaty. This is a simplified treaty which is very complicated, Luxembourg Prime Minister Jean-Claude Juncker quipped.

The tense summit was French President Nicolas Sarkozy's first and British Prime Minister Tony Blair's last.

Sarkozy injected a feverish activism into the quest for what he dubbed a simplified treaty, while Blair ended his decade in power without having achieved his stated goal of putting Britain at the heart of Europe.

Instead, he was forced to negotiate exemptions and opt-outs from key parts of the treaty to avoid a referendum which his successor-in-waiting, Gordon Brown, would almost certainly lose.

London won an exemption from the application in Britain of a legally binding EU Charter of Fundamental Rights, as well as the right not to join police and judicial cooperation.

Eurosceptic critics fear a dilution of national sovereignty but many of the 18 countries that had ratified the constitution were dismayed to see the document watered down.

The leaders agreed on a new position to run EU foreign policy, but without the constitution title of foreign minister.

It will combine the existing jobs of foreign policy chief Javier Solana, who does mostly crisis management, and External Relations Commissioner Benita Ferrero-Waldner, who controls the executive European Commission's big aid budget.

The new official will chair meetings of EU foreign ministers and head a combined external action service drawing on both national and EU diplomats from 2009.