Media playback is unsupported on your device Media caption Nicolas Sarkozy said he would have preferred a treaty among all the members of the EU

EU members which use the euro have agreed to a tax and budget pact to tackle the eurozone's debt crisis.

But a German and French attempt to get all 27 EU states to back changes to the union's treaties was dropped after objections from the UK.

Prime Minister David Cameron had insisted on an exemption for the UK from some financial regulations.

Instead, eurozone members and others will adopt an accord with penalties for breaking deficit rules.

The new tougher rules on spending and budgets will now be backed not by an EU treaty but by a treaty between governments. It will be quicker to set up but it may prove less rigorous, says the BBC's Europe editor Gavin Hewitt in Brussels.

But, he says, Europe has taken a big step towards closer integration, with binding rules over tax and spending, and sanctions against countries that overspend.

European Council President Herman Van Rompuy said the leaders of 26 countries had indicated a desire to participate, pending consultation with their parliaments.

Analysis There is now a two-speed Europe - after this long night, the French president accepted that. There is, too, considerable antagonism towards Britain - it used its veto in what is seen in Brussels as Europe's hour of need. What is unclear is whether European institutions can be used to implement a treaty between governments. If EU officials are in the room, David Cameron has already laid down a marker that he expected the UK to be involved. It is all a recipe for further tussles. The big question is what effect all this will have on the eurozone crisis. The main impact will lie in the long-term - the agreement has little to say about the debt mountains and the absence of growth in most of Europe. Read Gavin's thoughts in full

Mr Cameron said he had not signed up to the deal because, he said, it was not in Britain's interests.

"Those countries that sign this treaty... we wish them well because we want the eurozone to sort out its problems, to achieve that stability and growth that all of Europe - Britain included - needs," he said.

EU leaders aim to have the pact ready to take effect by March.

Among the measures agreed on, leaders pledged to provide more money for the International Monetary Fund (IMF) to fund bailouts.

IMF chief Christine Lagarde welcomed the deal as "a really good step in the right direction".

But the announcement from Brussels failed to lift the markets, which are still hoping for more intervention by the European Central Bank (ECB), and European stocks traded slightly down on Friday.

German praise

Nearly 10 hours of talks could not produce an agreement involving all member states. Instead, the 17 members of the eurozone will work on a separate deal outside EU treaties. They will be joined possibly by nine other countries, the EU statement said, leaving the UK as the only exception.

On Friday, Danish Prime Minister Helle Thorning-Schmidt said she would have to consult parliament before agreeing to sign up, according to a Danish press report.

Hungary's Europe Minister Eniko Gyori told the BBC her country was willing to join with the consent of parliament - contradicting earlier reports. A revised EU statement said Hungary had signalled its intention to join the process.

Mr Sarkozy said the sticking point had been Mr Cameron's insistence on a protocol allowing London to opt-out on proposed change on financial services.

"We could not accept this," he said.

During the talks, eurozone leaders agreed to work on new budgetary rules, which envisage automatic penalties.

The main measures agreed to as part of the new agreement, called a "fiscal compact" include:

Media playback is unsupported on your device Media caption David Cameron: It is better to have eurozone countries make arrangements separately

a cap of 0.5% of GDP on countries' annual structural deficits

"automatic consequences" for countries whose public deficit exceeds 3% of GDP

the tighter rules to be enshrined in countries' constitutions

European Stability Mechanism (ESM) to be accelerated and brought into force in July 2012

adequacy of 500bn-euro (£427bn; $666bn) limit for ESM to be reassessed

Eurozone and other EU countries to provide up to 200bn euros to the IMF to help debt-stricken eurozone members

The German Chancellor, Angela Merkel, praised the plan of action, saying it would contribute to securing the euro.

"I believe that after long negotiations this is a very, very important result because we have learned from the past and from mistakes and because in future [there will be] binding decisions, binding rules, more influence from the commission, more community and with that higher coherence."

ECB chief Mario Draghi said the accord would lead to much more discipline in economic policy, calling it "a very good outcome for the euro area".

Our correspondent says the immediate test will be whether this agreement persuades the ECB to act more aggressively in the markets and so lower the borrowing costs of troubled countries like Italy and Spain.