Greece's embattled government survived a confidence vote on Wednesday that was crucial to avoiding a sovereign debt default as thousands of protesters chanted insults outside parliament

The assembly voted confidence in the government, reshuffled by Prime Minister George Papandreou to stiffen resolve behind a painful new austerity program, by 155 votes to 143 with two abstentions.

All Papandreou's Socialist Party deputies voted solidly with the government.

If we are afraid, if we throw away this opportunity, then history will judge us very harshly, Papandreou said in a final appeal for support before the vote.

Protesters had besieged the parliament building during the vote, shouting insults at politicians and shining hundreds of green laser lights at the building and at Greek police. They held up a mock gallows with several nooses.

The crowd mostly dispersed afterwards, but police in full riot gear fired several rounds of tear gas to disperse a smaller group of youths continuing to protest. There were no immediate reports of injuries or arrests.

The successful poll, closely watched outside Greece, immediately spiked the euro higher, but the gains were short-lived as traders cited concerns about implementation of the deeply unpopular austerity measures.

The reaction of the people is going to be critical. If we see cars burning and protests tomorrow, then all this short term success is going to get sucked out the window, said William Larkin, a fixed-income portfolio manager at Cabot Money Management in Salem, Massachusetts.

European Commission President Manuel Barroso expressed immediate relief. Tonight's vote in the Greek Parliament removes an element of uncertainty from an already very difficult situation, he said, adding that Papandreou could now concentrate on implementing the reforms.

Although this clearly is not going to be a long-term fix, investors see this as a chance that the can will be kicked further down the road and so I think we are going to see tomorrow a world-wide push to risk assets, said David Dietze, Chief Investment strategist at Point View Financial Services.

Papandreou's government must rapidly pass two more tests -- enacting the austerity plan and the laws needed to implement it -- to win a new bailout to avert the euro zone's first sovereign default and possible global economic disaster.

ULTIMATUM

The vote follows a European ultimatum requiring the debt-choked Mediterranean state implement a new five-year package of deeply unpopular reforms in two weeks or miss out on a 12-billion euro aid tranche and plunge into bankruptcy.

Barroso had piled on pressure before the vote, saying that Greece faced a moment of truth and needed to show it was genuinely committed to the reforms.

No-one can be helped against their will, he said.

Acting IMF chief John Lipsky sent a similar message, saying international lenders were willing to help peripheral euro zone economies as long as they tried to carry out reforms.

He said the Greek fiscal system was broken but could be fixed with the right political will.

As parliament debated the confidence motion, demonstrators stepped up their protests in the square, where hundreds have camped for weeks to show their opposition to more austerity, which has deepened the worst recession for 37 years.

I believe we should go bankrupt and get it over with. These measures are slowly killing us, said 22-year-old student Efi Koloverou. We want competent people to take over.

Glykeria Madaraki, a 39-year-old unemployed woman, said: God help us. There is no way these people are getting us out of the crisis. I feel insecure and I see my country being sold off. They didn't ask what we think about all this. I want elections.

Inside parliament the opposition poured similar disdain on the government. This is not a program to salvage the economy, it's a program for pillage before bankruptcy, said Alexis Tsipras, head of the small opposition Left Coalition.

Finance Minister Evangelos Venizelos, in an attempt to answer a key grievance of protesters, told parliament the government's top priority would be to build a fairer tax system.

Papandreou stifled dissent within the party last week by replacing unpopular government figures with critics of the plan. The government must hammer through the five-year package of 28 billion euro ($39.84 billion) in tax hikes and spending cuts by June 28.

It must then push through laws implementing the reforms -- potentially more difficult as it will tackle individual privatizations, tax measures and spending cuts -- in time for an extraordinary meeting of euro zone finance ministers on July 3.

The cabinet will meet on Wednesday afternoon to approve a draft bill implementing the measures, officials said.

The government had been widely expected to survive the confidence vote. Defeat would have led to political chaos and early elections which PASOK would likely lose.

Greek bank shares gained more than 6.0 percent and 10-year Greek bonds rose in a sign of optimism on Tuesday. European and U.S. shares also rose, with the Nasdaq showing its biggest gain since October.

Having already missed targets agreed in its first, year-old bailout, Athens needs the reforms if it wants to receive the next tranche of those funds and secure a second bailout worth an estimated 120 billion euros.

The new mid-term plan envisions raising 50 billion euros by selling off state firms and includes 6.5 billion in 2011 fiscal consolidation, almost doubling existing measures that have helped extend a deep recession into its third year.

Most analysts remain skeptical that Greece will be able to reduce its vast sovereign debt pile of 340 billion euros, or more than 30,000 euros for each of its 11.3 million people, even if the reforms are implemented.

Inspectors from the International Monetary Fund and European Union arrived on Tuesday to examine a request by newly appointed Finance Minister Venizelos for changes to the mid-term plan. Greece's government has said the lenders' inspectors would discuss changes at a technical level.

Euro zone officials have told Reuters the plan for the new bailout, meant to extend Greece's year-old 110-billion-euro deal and fund it into late 2014, would feature up to 60 billion euros of fresh official loans, 30 billion euros from the private sector and 30 billion euros from privatizations.

(Additional reporting by Renee Maltezou, Lefteris Papadimas in Athens and John O'Donnell in Brussels; writing by Barry Moody and David Lawder; editing by Alistair Lyon)