Greece's parliament early on Thursday narrowly approved a sweeping bill of reforms tied to the country's next tranche of EU-IMF loans.
The coalition government's majority carried most of the tougher articles that had caused days of street protests by a majority of 153 to 140, the parliament speaker said.
Under the proposed reforms, thousands of civil servants including teachers and municipal police will have eight months to find new posts elsewhere or accept those offered to them. Otherwise, they would lose their jobs.
It was a close call for the coalition government which has a five-seat majority in the chamber.
Two government deputies did not attend the vote, and a third had to be brought out of hospital to cast his ballot, reports said.
Hundreds of protesters had gathered outside parliament for the late-night vote, a day after thousands had demonstrated in a general strike called against the reform.
About 4,200 state staff are due to be redeployed already by the end of July.
Overall, Greece must redeploy 25,000 civil servants and fire another 4,000 by the end of the year.
The main opposition Syriza leftists have called the measure "human sacrifice" and said the country's creditors were motivated by "hatred" for demanding it.
Prime Minister Antonis Samaras defended the unpopular measure, promising "better days" for Greeks as he announced a 10-percent drop in restaurant sales tax to boost the tourist season.
"Better days will come for our people," Samaras said in a televised address hours before the vote.
"We will not let up. We will climb uphill and reach the end, which is not far."
Samaras has been under heavy pressure this past month to hold his government together after losing one of his coalition allies in June in the wake of an earlier round of job cuts affecting state broadcaster ERT.
On Thursday, German Finance Minister Wolfgang Schaeuble is holding a rare visit to Athens, reportedly to help set up a support fund for struggling businesses.
The visit poses another challenge for authorities, who will throw a large security cordon around Athens to ward off possible protests against Schaeuble. He is seen here as a champion of the tough austerity policies that have gripped Greece like a vice for the past four years.
The bill's approval will enable Greece to receive its next instalment of 6.8 billion euros ($8.9 billion) in rescue funds cleared by eurozone finance ministers.
The size, cost, efficiency and contractual conditions of the public sector workforce in Greece have been in the sights of the IMF and EU ever since they moved in with the bailout programme and associated conditions for reforms.
The bill also covers a partial overhaul of the tax system, including the introduction of new criteria for taxable income and the adjustment of tax thresholds.
About 4,000 civil servants, according to a police source, gathered on Wednesday in Athens' central Syntagma square near the parliament to protest against the vote.
Municipal employees have been on strike since Monday, with garbage piling up in the streets as a result.
On Tuesday, more than 20,000 people protested in Athens and Greece's second city Thessaloniki during a general strike called by the main unions.
Some 52 specialities taught at public vocational schools will also be abolished from next week according to the bill, which leading union GSEE has called a "tombstone" for Greek workers.
Greece has been forced to implement a series of painful reforms over the past four years in exchange for 240 billion euros in rescue funds put up by the European Union and International Monetary Fund.
The sweeping job, pay and pension cuts have hit Greeks hard, sparking mass protests and general strikes.
Now in its sixth year running of recession and with the unemployment rate at a record 27 percent, Greece is not expected to post growth before 2014.