European Union leaders sealed a new fiscal pact ensuring tougher budget discipline but failed to agree on a treaty change to enshrine the rules, meaning a deal may now involve the 17 euro zone nations plus any others that want to join, diplomats said.

An agreement involving all 27 EU members fell through - raising the prospect of a two-speed Europe - after British Prime Minister David Cameron demanded concessions that Germany and France were not willing to give, one of the officials said.

We've always said we would do it at 17 if it didn't work at 27. That's what happened, one senior EU diplomat told Reuters.

The EU leaders, meeting in Brussels, agreed on automatic sanctions for euro area deficit offenders unless three-quarters of states vote against the move, and approved a new fiscal rule on balanced budgets to be written into national constitutions.

There is a deal between leaders on the new fiscal compact, an EU official told reporters.

After nearly 10 hours of talks running into the early hours of Friday morning, they also decided that the currency bloc's future permanent bailout fund, the ESM, would be capped at 500 billion euros, as Germany had insisted.

It will also not get a banking license, which would have allowed it to draw on European Central Bank funds to increase its firepower, another move Germany objected to.

As soon as the draft summit agreement leaked late on Thursday, a senior German official rejected key measures including letting the future rescue fund, the European Stability Mechanism, operate as a bank, and a long-term goal of issuing common euro zone bonds.

Shares and commodities fell, while the euro remained under pressure, on growing doubts that Europe could forge a credible plan to solve the euro zone's debt crisis.

European Council President Herman Van Rompuy, the summit chairman, wanted all 27 EU states to agree to the rule changes via a minor adjustment to a treaty protocol that could be implemented quickly without requiring full ratification.

But German Chancellor Angela Merkel demanded a fully fledged treaty change to give the measures extra weight.

Merkel and French President Nicolas Sarkozy had said that if all 27 EU states did not support more fiscal union by adapting the existing Lisbon treaty, which took eight years to negotiate,

then the 17 euro zone countries should press on alone with more integration.

The danger for Cameron is that if a large majority of EU countries do push ahead with deeper integration, it could involve discussions over changes to the single market and financial regulation, both of which could have a profound impact on the British economy.

Cameron was clumsy in his maneuvering, another senior EU diplomat said. Efforts continued to get the British to shift their position.

DRAGHI DOWNBEAT

ECB President Mario Draghi spooked financial markets on Thursday by discouraging expectations that the bank would massively step up buying of government bonds if EU leaders agreed on moves towards closer fiscal union.

Draghi said the bloc's existing bailout facility should remain the main tool to fight bond market contagion, despite its clear limits. It was illegal for the ECB or national central banks to lend money to the IMF to buy euro zone bonds, he said, appearing to veto one firefighting option under consideration.

One step forward, two steps back, said Alan Clarke, UK and euro zone economist at Scotia Capital. The euro zone leaders might as well not bother. Pack their bags, go home, enjoy the weekend and do their Christmas shopping.

The new ECB chief said his recent remark that other elements might follow if euro zone leaders agreed to seal tougher new budget rules had been over interpreted as hinting the bank could step up bond purchases.

The plight of Europe's banks was thrown into sharp relief. The European Banking Authority told them to increase their capital by a total of 114.7 billion euros, significantly more than predicted two months ago.

A Reuters poll of economists found that while 33 out of 57 believe the euro zone will probably survive in its current form, 38 of those questioned expected this week's summit would fail to deliver a decisive solution to the debt crisis.

IMF

The EU leaders agreed to explore the option of euro zone central banks making bilateral loans to the International Monetary Fund to the tune of 150 billion euros with the hope that a further 50 billion would come from donors outside Europe.

Although the ECB chief ruled out the IMF buying euro zone bonds, that left the option of lending directly to governments as it more customarily does, although Italy for one has insisted it needs no such assistance.

France and Germany had pressed to amend the European Union treaty to toughen budget discipline, which they want to have ready by March. But countries other than Britain were skeptical of full-blown treaty change.

Swedish Prime Minister Fredrik Reinfeldt, speaking for a non-euro state, said: We want to stick with the 27 concept of course because all of us are members of the European Union and we want to have our influence. We want to keep the European project together.

However, he said there was no support in Sweden for treaty change as of now.

The Franco-German plan would slap automatic penalties on countries that overshoot deficit targets and make countries anchor a balanced budget rule in their constitutions.

General government budgets shall in principle be balanced. Member states may incur deficits only to take into account the budgetary impact of the economic cycle or in case of exceptional economic circumstances, the draft summit conclusions said.

The sanctions could be stopped only if three quarters of euro zone countries are against them.

(Additional reporting by Catherine Bremer in Marseille, John O'Donnell and Jan Strupczewski in Brussels, Eva Kuehnen and Sakari Suoninen in Frankfurt, and Terhi Kinnunen in Helsinki; Writing by Mike Peacock)