Greek Prime Minister George Papandreou on Tuesday won a critical vote of confidence in Parliament, helping pave the way for $17 billion in emergency loans needed to keep his beleaguered country solvent.

Papandreou’s governing socialist party holds a slim 155-seat majority in the 300-member assembly, and public anger has been mounting over the country’s ongoing recession and the deep cuts to social programs demanded by the International Monetary Fund and other European countries as a condition for the emergency loans.

But after a cabinet reshuffle last week — and with the Greek government otherwise facing an imminent financing crisis and possible default on its bond payments — Papandreou prevailed in a party-line vote, 155 to 143, with two abstentions, even as thousands of protesters booed outside.

“We must follow this course to save the country,” Finance Minister Evangelos Venizelos said, addressing lawmakers ahead of the vote, according to wire reports. “Distrust” that Greece won’t follow through on reforms “is something we have to change,” he said.

Major stock exchanges on Wall Street and in Europe were sharply higher throughout the day on the expectation that Papandreou would hold on to power.

But Tuesday’s confidence vote is only the first of several hurdles for Greece — and for European and IMF officials, who must craft a longer-term solution for the country’s problems.

The IMF has been warning this week that fraying political support for economic reform and government debt reduction in Europe could derail the region’s already slow recovery and damage the global economy. The point was reemphasized Tuesday when the agency cautioned that recent efforts to bring government borrowing under control in Spain are “incomplete.”

Three smaller European countries — Greece, Ireland and Portugal — are under emergency programs jointly funded by the IMF and the 17 nations that share the euro as a currency, but a bailout of larger Spain would be difficult.

With his authority as prime minister reaffirmed, Papandreou’s next test will come in a week, when he must persuade Parliament to approve more budget cuts, tax increases and other concessions needed to secure more rescue loans.

Opponents promised a fight over whether Greece should continue under a program that many in the nation think has driven their economy into a deeper-than-expected recession without clear evidence of the expected growth.

Thousands gathered in Syntagma Square in Athens, outside the parliament, flashing green laser pointers at the building and criticizing the program crafted for the country by the IMF and European powers such as Germany.

“We don’t want the austerity measures that will lead to the country’s death,” a woman shouted from the square.the main site of demonstrations that pushed Papandreou’s government near collapse.

In cabinet changes last week, Finance Minister George Papaconstantinou, an architect of the unpopular IMF-endorsed reform program, was dismissed and Venizelos, a veteran socialist whose presence helped stop defections from Papandreou’s party, was brought in.

Labor unions have called a two-day strike ahead of next week’s vote.Simon Tilford, chief economist at the Centre for European Reform, a think tank in London, predicted a tough fight for Papandreou in the coming week — and no guarantee that Greece is close to renewed growth.

“No government in Europe would be able to push through austerity of this level without light at the end of the tunnel. And there is no light,” Tilford said. “The economy is pretty much in free fall.”

Special correspondents Elinda Labropoulou in Athens and Karla Adam in London contributed to this report.