By the end of a vital two-day summit here, European diplomacy had played out like soccer, with Spain and Italy — the two nations headed to the Euro 2012 finals — emerging victorious and the Germans returning home in shock.

After 14 hours of talks, Berlin unexpectedly agreed to concessions clearing the way for a deal that could help both Madrid and Rome in their desperate efforts to stave off economic collapse.

The agreement, while conditional on the creation of a regulatory body, addressed the core of the questions facing Europe: Who will cover the tab for its 2½-year-old debt crisis, and how?

Under the terms of the deal, troubled euro-zone countries would have more options for aid, including using a pool of European rescue funds to directly recapitalize ailing banks. That, in turn, would spare governments the humiliation of having to ask for aid themselves to channel to domestic banks, sidestepping the kind of intrusive financial inspections imposed on Greece, Ireland and Portugal.

The change could ultimately halt a toxic cycle that, while holding countries accountable for their banks’ errors, also pushed indebted nations deeper into the red as they took on ever more rescue cash to bail out their financial institutions.

The agreement in Europe delighted global investors, who sent stocks soaring. In the United States, the Standard & Poor’s 500-stock index rose 2.5 percent Friday, the sharpest increase since December, and the Dow Jones industrial average was up 2.2 percent. The strong performance capped the stock market’s best June since 1999. In Europe, investors were even more exuberant, with the German DAX and the Stoxx index of major euro-zone companies both jumping more than 4 percent.

The plan is to kick in only after a regional supervisor, based at the European Central Bank, is set up to regulate banks in the 17-nation euro zone — itself a major step that leaders said they would sign off on by the end of the year.

In addition, leaders agreed that countries could obtain bailout funds to buy up their government bonds on open markets — and thus bring down dangerously high borrowing costs — with fewer conditions attached.

‘Unthinkable’ decisions

The compromise reached here Friday fueled new optimism about the region’s ability to finally break the diplomatic impasses that have made its debt crisis as much political as economic.

“We have taken decisions that were unthinkable just some months ago,” European Commission President Jose Manuel Barroso said.

The breakthrough also signaled a reshaping of Europe’s political landscape.

German Chancellor Angela Merkel, the frugal East German physicist, had laid down the rules for coping with the crisis through her alliance with Nicolas Sarkozy when he was France’s president. But with his successor, the socialist Francois Hollande, leaning more toward the Italian and Spanish leaders’ vision of crisis management, a new three-against-one dynamic took hold here.

Backed by the French, Spanish Prime Minister Mariano Rajoy, a conservative who is protective of Spanish pride, and Italian Prime Minister Mario Monti, a sober and respected former E.U. official, resorted to brinkmanship. Both leaders vowed to block a $150 billion growth plan, seen as a centerpiece of the forum, if they did not win major concessions. Against their united front, Merkel blinked.

“The discussions were hard and tense,” Monti said Friday. “But it was worth the effort.”

Hollande, meanwhile, reiterated his support. “If Italy and Spain applied pressure during the night,” he said, “it was so the whole euro zone would come out stronger.”

He also hinted that Merkel would continue to face a tough new bloc against the conservative German approach to the crisis.

“This was not France and Germany arriving with a solution, like in the past,” Hollande said Friday, according to a translation by Reuters. “It was France and Germany, along with others, reaching a solution. That’s why it took so long and went so far.”

The goals scored here by the Spanish and Italians could buy them more time to make tough economic reforms, boosting investor confidence. But they do not guarantee that Spain and Italy can avoid a deeper crisis that could yet shatter the euro currency union, and Europe will probably still need to dedicate far more cash than it already has to prop up the region’s ailing economies.

Merkel’s risks

Merkel and European Central Bank chief Mario Draghi warned Friday that the new flexibility governing Europe’s rescue fund should not be seen as a blank check, with Draghi saying access to funds would still come with “strict conditionality.”

Merkel’s decision to back down carries domestic political risks, with the German public growing weary of its indebted neighbors’ woes. She survived a key test late Friday when the German parliament approved Europe’s new budget-discipline pact as well as the euro zone’s new, permanent $623 billion rescue fund.

Earlier in the day, though, her home media savaged her: “Italy and Spain broke the will of the iron chancellor by out-negotiating her,” Germany’s Der Spiegel declared on its Web site Friday.

Still, few appear to think the German chancellor will easily bend on other, more major issues yet to be worked out. In the fight for bigger fixes to the euro — such as collective debt shared by the 17 nations of the euro zone — Merkel will probably be less flexible, demanding that her neighbors cede more power to a central authority here in Brussels and make more spending cuts in exchange for the promise of further German aid.

The agreement that Rajoy and Monti secured, allowing European rescue funds to be used to directly recapitalize banks, rather than just national governments, remains conditional on the creation of the regional banking supervisor, still several months away.

Theoretically, that means that Spain, which has already requested a bailout of as much as $125 billion to aid its troubled banks, would still need to run its initial rescue through the national government. But the government could potentially step down by the end of the year, allowing the banks to directly obtain aid and potentially bolster market confidence in the government’s ability to service its debt. In another key concession, the Germans agreed to drop a requirement giving the European rescue fund, to which Germany is the largest donor, preference over private investors in Spanish government debt in the event of a default.

Monti also hailed a concession allowing countries to tap bailout funds to buy government bonds with fewer strings attached. But the wording of the agreement remained vague, and Merkel warned Friday that there would still be conditions, with countries expected to adhere to E.U. budget targets and European authorities reviewing their compliance.

The deal suggested that Italy was already pondering such a move, which would make it the sixth nation in Europe to request some form of assistance. But Monti insisted Friday that Rome was not yet considering a request.

Leaders were also set to debate more radical steps toward European integration at the summit, including the establishment of a banking union and a European Treasury that could hold sway over national budgets. But discussions on the longer-term fixes were postponed until October, setting up a pivotal new crunch time when Merkel will face the tough political challenge of securing a path forward for Europe that the German public can live with.

Herman Van Rompuy, head of the European Council, a body made up of the region’s leaders, said Friday that the October report would offer “a specific and time-bound road map for the achievement of a genuine economic and monetary union.”

Edward Cody in Paris and Alan Sipress in Washington contributed to this report.