The deal, signed after a marathon negotiating session at the Edinburgh summit, staved off the collapse of the Maastricht treaty and gave new impetus to the EC after perhaps the worst year in its existence.
Mr Major told a closing news conference that EC leaders had faced more difficult interlocking problems than at any recent European council 'but I believe we can say today we have solved the Rubik's Cube'.
The 12 leaders also agreed to begin formal negotiations on enlarging the Community from 1 January. The success for the British presidency under John Major was bought at the price of higher EC spending and increased pressure for Britain to ratify the treaty before mid-summer.
The deal, designed to meet Denmark's objections to the treaty, promised to restore a sense of unity - provided it proves acceptable to the Danes in a second referendum. Uffe Ellemann-Jensen, Denmark's foreign minister, praised the 'persistence and ingenuity' of the British presidency and added: 'We have got what we wanted.' He said that the agreement opened the way to a referendum 'not later' than April or May. The Danish deal broke the back of a problem that has bedevilled the EC since Danish voters rejected the treaty in June.
It includes declarations spelling out Denmark's status within the Community, and a summit 'decision' confirming the country's exemption from key parts of the treaty. Much now depends on how the agreement is received by the Danish anti-Maastricht camp. 'In my view it's not legally binding,' said Jens-Peter Bonde, a leading campaigner. 'It should go to the Luxembourg court.'
The success of the Danish deal paved the way for a late night agreement on the EC's future financing. The 12 EC member states have agreed that the budget should be increased to about 1.27 per cent of total Community wealth by the year 1999 - 83bn ecus ( pounds 66bn). Britain had orginally put to the EC plans for an increase to 1.25 per cent of gross national product, or 80bn ecus. The difference amounts to some pounds 2.5bn a year by 1999.
The summit was delayed by fierce wrangling over the insistence of the Spanish prime minister, Felipe Gonzalez, that a higher share of the resources within that total should be allocated to Madrid.
Earlier there had been private irritation in the British camp that Germany had threatened to undercut its negotiating strategy by implying that the budget might be increased from the revised British proposal to 1.3 per cent of GNP.
With financial markets threatening to upset the European Monetary System, a deal now will give an added psychological bonus to fragile economies. Jacques Delors, the European Commission president, had earlier warned all the 12 they risked giving the markets a signal of division.
Success was the result of a carefully handled negotiation. British officials indicated that by tabling budget proposals early, many of the arguments had been brought into the open before Edinburgh.
The Danish issue was then placed first on the agenda, and was all but resolved on Friday. This left the second day for the tough budget rows.
Mr Delors was privately enthusiastic about the virtues of the British presidency at the summit. Only weeks ago, in a private meeting with Mr Major, he threatened to resign.
The EC leaders agreed that they could push ahead with negotiations on enlarging the Community, a key British aim. The summit also resulted in new agreements on subsidiarity - the principle that decides when and how the 12 should act as a Community.
A package of measures to boost growth was put together, though it was far more modest than earlier proposals.
A Danish referendum in April or May could unlock the process for ratification by Britain after completion of the Maastricht Bill's passage through the Commons by late June or July. There are growing signs that Labour will not oppose the third reading of the Bill or otherwise sabotage the treaty.
Further reports, page 2