European Union leaders have reached agreement in Brussels on an outline of new rules to govern the 27-member bloc.
Germany had made a new treaty a priority of its EU presidency
At dawn on Saturday they announced a compromise to delay until 2014 a new voting system that reduces Poland's influence - the main stumbling block.
Other proposals envisage a long-term president and a foreign affairs head.
The new treaty, expected to be finalised later this year, preserves much of the planned EU constitution, which was rejected by voters in 2005.
The treaty will need to be ratified by each of the EU's member states, before entering into force in mid-2009.
Devil in detail
After two years of uncertainty, the road for EU reforms is clear, says the BBC's Oana Lungescu in Brussels.
And following marathon discussions which were at times on the brink of failure, EU leaders emerged smiling at dawn on Saturday to announce the results.
Having led the negotiations and brokered the compromise, German Chancellor Angela Merkel, the current EU president, said: "We are very, very satisfied with what we have been able to conclude."
The President of the European Commission, Jose Manuel Barroso, paid tribute to Ms Merkel and handed her a bunch of flowers.
"This shows that Europe is on the move, and on the move in the right direction."
Mrs Merkel conceded the talks had been hard - with Poland, the UK and the Netherlands each staunchly defending their interests.
The main obstacle had been Poland's demand to keep its voting power, which is currently almost equal to that of Germany's, even though its population is only half as large.
The new system - known as a "double majority" - will now be phased-in beginning in 2014 and fully implemented three years later.
Under this system, a 55% majority of EU countries with at least 65% of the bloc's population will be required for a change to be approved.
The treaty is also set to include most of the main points of the failed constitution, such as:
- a full-time president of the European Council - the regular gatherings of prime ministers and presidents
- a new foreign affairs chief, with the profile and the budget to give the EU more clout on the world stage
- fewer national veto powers
- more powers for the European Parliament
- a slimmed-down European Commission (from 2014)
Britain and the Netherlands also got what they wanted from the summit.
"The four essential things that we in the UK required in order to protect our position have all been obtained," said Tony Blair at the end of his last EU summit as British prime minister.
"Those were first of all to make it absolutely clear that the charter on fundamental rights was not going to be justiciable in British courts or alter British law."
Mr Blair also wanted to maintain national control over foreign policy, justice and home affairs.
The Netherlands, too, was satisfied that the role of national parliaments in Europe is to be strengthened and the criteria for new members joining the EU are included in the treaty.