Britain and Poland threaten to use their veto if demands are not met.
In 2005, French and Dutch voters rejected an EU constitution in national referendums.
“We have managed to organise things so that no one can go home and feel they have been put in the corner”
Discussions at the recent summit, chaired by Germany, which currently holds the rotating presidency of the EU, were held up by other nations, including Britain and Poland.
Angela Merkel, the German chancellor, described the treaty as a “good compromise”.
“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,” Merkel said.
“We have managed to organise things so that no one can go home and feel they have been put in the corner.”
Poland, led by Lech Kaczynski, the Polish president, was strongly opposed to a treaty, fearing it would limit Poland’s voting rights.
EU Leaders finally settled for a deal that put off introduction of a new voting system until 2017 and other concessions proposed by Germany, diplomats said.
Alberto Navarro, Spain’s Europe minister, said: “They convinced him [Kaczynski] and there was a deal.”
Poland was also offered guarantees that the rest of the bloc would back it in the event of future disagreements, principally with Russia, over energy, diplomats said.
Kacynski called the result “very encouraging” for Poland.
Britain also had strong objections to the treaty, but said the compromise had met all of its “red lines” on issues such as expanding EU powers over labour and justice, a spokesman for Tony Blair, the British prime minister, said.
Several countries also objected to a clause on morality and family law, introduced to appease Poland, which they argued undermined the EU’s commitment to civil rights, diplomats said.
Earlier on Friday, the EU had reached a broad agreement on creating a new, single post to run the bloc’s foreign affairs.
The EU leaders agreed on the job title, role and powers of a high representative of the EU for foreign policy, defence and security.
The post will combine the jobs of Javier Solana, the foreign policy chief who does mostly crisis management, and Benita Ferrero-Waldner, external relations commissioner who controls the executive European Commission’s aid budget.
The new foreign policy chief would chair meetings of EU foreign ministers and head a combined external action service drawing on both national and EU diplomats, after Britain dropped its reservations on those points, the diplomats said.
Leaders hope the draft treaty will be agreed at an intergovernmental conference later in the year.