All but two of the EU's 27 leaders have signed a new treaty to enforce budget discipline within the bloc.

The "fiscal compact" aims to prevent the 17 eurozone states running up huge debts like those which sparked the Greek, Irish and Portuguese bailouts.

To take effect, the pact must be ratified by 12 eurozone states.

UK Prime Minister David Cameron, who with the Czechs refused to sign, said the summit had accepted his ideas for cutting red tape and boosting growth.

On Thursday he had complained that his ideas, contained in a joint letter signed by 12 EU leaders, were being ignored.

But after the talks he said "our letter really did become the agenda for this meeting... We now have a plan that we must stick to in the months ahead".

The newly reappointed President of the European Council, Herman Van Rompuy, said the British proposals were being taken seriously and he had sought to redraft the summit's conclusions accordingly.

Critics argue that the fiscal treaty is mainly a political gesture aimed at reassuring taxpayers in Germany, the eurozone's dominant economy, where there is reluctance to pay for further eurozone bailouts.

German Chancellor Angela Merkel described it as a "great leap", a first step towards stability and political union.

Germany is reluctant to increase the size of the permanent rescue fund, the European Stability Mechanism (ESM), which comes into force on 1 July.

The leaders put off until the end of March a decision on its size. There are calls to combine the 250bn euros (£209bn; $333bn) left in the temporary bailout fund - the EFSF - with the 500bn-euro ESM.

More budget pain

The fiscal pact emerged at an EU summit in December, where Mr Cameron vetoed plans to change the EU treaties so that greater budget surveillance would be enforced.

The pact may face an early test as both Spain and the Netherlands have admitted they will miss targets for reducing their deficits, BBC Europe editor Gavin Hewitt reports.

Spain, already struggling with painful public sector cuts, wants to negotiate a higher deficit target with the EU. But Brussels made no concessions on Friday.

While there was a change of emphasis at this summit, "from crisis mode to growth mode" in the words of one senior official, growth will be difficult to achieve whilst tough spending cuts are being made, Gavin Hewitt adds.

Whereas in the past even France and Germany broke the EU's deficit rules the new treaty is aimed at preventing such practices.

Eurozone countries will scrutinise each other's budgets and the European Court of Justice will be able to check whether nations stick to the rules. It will fine them up to 0.1% of national GDP if they fail to do so.

'Credibility at stake'

In a speech at the signing ceremony, Mr Van Rompuy said: "This stronger self-constraint by each and every one of you as regards debts and deficits is important in itself.

"It helps prevent a repetition of the sovereign debt crisis. It will thus also reinforce trust among member states, which is politically important as well.

"The restoration of confidence in the future of the eurozone will lead to economic growth and jobs. This is our ultimate objective."

The President of the European Commission, Jose Manuel Barroso, called the pact a strong political statement for the EU.

"In the eyes of the world what is at stake is the very credibility of the euro area and of Europe as a whole," he said.

The pact, he said, enhanced the euro's permanence "contrary to all the negative prophecies".

Irish vote

The fiscal compact will now go before national parliaments and, in the case of the Irish Republic, a referendum.

Ireland rejected the Lisbon Treaty in a referendum in 2008, before approving it a year later after obtaining EU concessions, but the success of this fiscal treaty is unlikely to depend on Irish voters.

Irish businessman Declan Ganley, a leading "No" campaigner in 2008, has said he may support the fiscal compact if Brussels offers Dublin better terms in bailing out its banks.

The chances of a "Yes" vote were around 50-50, he was quoted as saying by Reuters news agency.

While the compact only needs to be ratified by 12 of the eurozone states to take effect, any state which fails to back it will lose the right to future bailouts.

An international bailout worth about 85bn euros ($113bn; £72bn) was granted to Dublin in November 2010.