Updated

After tough all-night bargaining, European leaders appeared to salvage what had seemed to be a summit teetering toward failure by agreeing early Friday to use the continent's bailout fund to funnel money directly to struggling banks, and in the longer term to the idea of a tighter union.

The bank decision at overnight meetings in Brussels was aimed at helping Spain, which sought a euro100 billion rescue to help its troubled banks and wound up facing rising borrowing costs for the government.

European Council President Herman Van Rompuy called it a "breakthrough that banks can be recapitalized directly."

In addition, the leaders agreed that EU countries that were following budget rules could apply for bailouts that would not come with the stringent conditions that have accompanied previous EU bailouts -- a recognition, said Italian Premier Mario Monti, who pushed for the deal, of the work such countries were already doing in reforming their budgets.

Monti said Italy did not intend to apply for a bailout.

Still, Van Rompuy said the bailout agreement was important.

"We are opening the possibilities for countries that are well-behaving to make use of financial stability instruments, the EFSF and ESM, in order to reassure markets and get again some stability around some of the sovereign bonds of our member states," he said, referring to two bailout funds set up by the EU.

That meant, he said, that there would not be any more countries struggling under the stern conditions that have been imposed on previous EU countries that received bailouts -- an apparently sharp change in EU policy.

Van Rompuy said leaders of the 17-nation eurozone also agreed to a joint banking supervisory body. And he said the leaders of the full 27-member European Union agreed to a general long-term plan for a tighter budgetary and political union.

The importance of recapitalizing banks directly became evident when Spain asked for money for its shaky banks. Under current rules the bailout loan had to be made to the government, which would then lend it on to the banks. But having that debt on the government's books spooked investors, who began demanding higher interest rates for lending money to the government.

The result was rates that would have been unsustainable in the long term. Lending the money directly to the banks would avoid putting that debt on the government's books.

The leaders agreed on "the four building blocks" of a tighter European Union -- but said they wouldn't start pinning down details until a report in October. The building blocks were laid out in a sweeping document presented by Van Rompuy and colleagues earlier this week that included sharing debt in the form of jointly issued eurobonds.

Van Rompuy said the report expected in October would be "a specific and time-bound roadmap for the achievement of a genuine economic and monetary union."

"The aim is to make the euro an irreversible project," he said.

He did not say Friday, however, whether the general agreement on the tighter union included a firm commitment on Eurobonds from Germany -- which has firmly opposed sharing debt with more profligate countries such as Greece.