LONDON — A highly anticipated ruling by Germany’s Constitutional Court on Wednesday both helped and hurt Chancellor Angela Merkel’s battle to shore up the euro. The powerful panel of judges declared that bailouts to troubled nations were legal but also ordered that future rescues involving Germany must first be approved by a parliamentary panel.

Analysts and world markets appeared to breathe an immediate sigh of relief. European markets rebounded after three days of stark losses. The Euro Stoxx 50 closed higher at 3.4 percent, German DAX was up 4 percent; London’s FTSE index rose 3 percent; and France’s CAC advanced 3.6 percent.

In the United States, stocks opened higher and remained up throughout the day. At closing bell, all three major indexes had gained. The Dow Jones Industrial Average had advanced 2.5 percent; Standard & Poors was up 3 percent, and the tech-heavy Nasdaq had risen 2.9 percent.

In the worst-case scenario, the ruling could have upended attempts to stem Europe’s debt crisis through multibillion-dollar bailouts. The continent’s deepening economic woes have triggered fears that the crisis will spread into global markets, causing the kind of world financial meltdown that followed the collapse of Lehman Bros. in 2008.

Updated statistics showed that growth in the 17-nation euro area slowed sharply, to 0.2 percent, in the second quarter, compared with 0.8 percent for the first three months of the year. German factory orders fell in July.

The largest economy in the 17-nation euro zone, Germany has become increasingly hesitant about its role in the bailouts as angry taxpayers have been forced to bear the highest burden of the rescues.

Speaking to the German parliament on Wednesday, Merkel said the ruling validated her government’s pragmatic approach to the crisis. She compared the current debt struggle to the effort to rebuild Germany after World War II, portraying the euro as the region’s great unifying force.

“Europe must come out of this crisis stronger than it went in, just as Germany came out of the crisis stronger,” Merkel told lawmakers.

And yet, the ruling also amounted to at least a partial victory for opponents of bailouts — who argue that they violate European and German laws — with the court throwing up new barriers to future aid, as well as more radical fixes for the crisis.

The court ruled out any measure that would pool Germany’s debt with those of its neighbors. The judgment seems to preempt the notion of creating new “eurobonds” backed by the taxpayers of all euro-zone nations, and it erects a major new obstacle for those who see such bonds as the best chance for a lasting solution to the crisis.

That aspect of the ruling did not appear to trouble Merkel, at least not publicly. She openly spoke out against the euro-bond idea, calling it the “wrong answer” for Europe. Instead, she urged troubled euro-zone countries to win back confidence by facing up to the hard task of tackling their mountains of debt.

The ruling also effectively means that Merkel will need to win the approval of a parliamentary committee before she can agree to future bailouts. That extra step may not pose an immediate problem for the chancellor, as the current makeup of the committees generally support her moderate stance. Yet, as a flurry of regional elections have shown, German taxpayers are pressuring their politicians over the costs of rescue packages, and bailout opponents say those concerns will increasingly prompt German lawmakers to reject bailouts.

“I see this as a partial victory for us,” Dietrich Murswiek, one of the lawyers defending the case against the legality of the bailouts, said in an interview. “German taxpayers are weary of paying these billions of euros to Mediterranean countries. And their representatives are going to have to take responsibility for these decisions .… We already see pressure on political parties building.”

On Wednesday, France’s lower house of parliament approved a second European bailout for Greece and austerity measures, including tax increases and spending cuts, to shave France’s debts. The vote comes after Euro-area leaders met Tuesday in Berlin for further talks on an expanded rescue package for debt-plagued Greece. Several weeks ago, Finland demanded that Greece offer collateral in exchange for loans, adding another hurdle to the talks. Eurozone leaders agreed July 21 on a second aid package for Greece, but the plan must be approved by the governments of the 17 euro zone nations.

Workers marched in Italy and Spain on Tuesday to protest planned spending cuts by their governments to try to control debt and instill confidence among the other euro nations that the two countries will be able to pay their bills without international bailouts of the sort that Greece, Portugal and Ireland required this year.

Instead of making it easier for euro-zone nations to bail out their neighbors – as leaders have agreed to do – the German court ruling may instead make it harder.

“That is the point,” Murswiek said.

Washington Post staff writer Howard Schneider contributed to this report.