Angela Merkel, the German chancellor, chairing the summit at the end of Germany's presidency of the EU, had struggled to break Poland's opposition to the treaty which would cut Warsaw's voting power.
Merkel eventually threatened to move ahead with the treaty regardless of Warsaw's objections.
The treaty is designed to replace the EU constitution that was rejected by voters in France and the Netherlands in 2005.
Poland finally settled for a deal that put off introduction of the new voting system until 2017 and other concessions proposed by Germany, diplomats said.
Warsaw was also offered guarantees that the rest of the bloc would back it in the event of future energy crises, a concern of Poland which borders giant gas and oil exporter Russia, diplomats said.
Britain had strong concerns about the treaty too but was confident that the deal met all of its "red lines" on sensitive issues such as expanding EU powers over labour and justice, a spokesman for Tony Blair, the British prime minister, said.
The agreement would not require Britain to a referendum on the treaty, the official said.
Merkel wanted the deal so that the EU could tackle challenges such as global warming and simplify its decision-making structures after following its enlargement from 15 to 27 member states, but critics fear a dilution of national sovereignty.
The leaders had earlier on Friday scored a first success in their summit by reaching a broad agreement on creating a new, single post to run the 27-nation 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.