Lawmakers approved the spending cuts, tax hikes and measures making it easier to hire and fire workers after nearly 100,000 Greeks waving flags and chanting "Fight! They're drinking our blood!" descended on Syntagma Square in central Athens.
Despite the abstention of their junior ruling partner the Democratic Left, Prime Minister Antonis Samaras's New Democracy Party and its Socialist PASOK allies passed the 500-odd page bill shortly after midnight.
They mustered 153 of parliament's 300 seats, with New Democracy and PASOK expelling seven deputies from their ranks for not backing the measures.
Earlier in the evening, clashes erupted when a handful of protesters tried to break through a barricade to enter the assembly. Riot police responded with teargas, stun grenades and, for the first time in an anti-austerity protest here, water cannon.
There was also chaos inside the assembly, where parliamentary workers briefly stopped the session by walking out when they discovered their salaries would be cut.
The bill covering the bulk of €13.5 billion worth of belt-tightening measures is a precursor to the 2013 budget law, which the government is expected to push through on Sunday.
If it does, it is expected to unlock a €31.5 billion aid tranche from the International Monetary Fund and European Union that Greece needs to shore up its banks and pay off loans.
"We must now pass the budget and right after that work for the recovery of the economy," Samaras said after the vote.
The vote came on the second day of a two-day national strike called by the country's two biggest unions, which halted public transport and shut schools, banks and government offices. Garbage piled up on the streets.
Backed by the leftist opposition, unions said the measures would hit the poor and spare the wealthy, while deepening a five-year recession that has wiped out a fifth of the country's output and driven unemployment to a record 25%.
Anger has also been growing at the relaxed approach consecutive governments have taken towards catching tax cheats, with many saying officials have dragged their feet on investigations to protect a wealthy elite.
Outside parliament, loud booms rang out through the evening as hooded protesters wearing gas masks hurled molotov cocktails and rocks at police. Billowing smoke and small fires dotted the square and streets next to parliament.
At least 35 people were detained. There were no reports of serious injuries, police said.
Ball in EU court
Calm returned as protesters emptied the square during a steady downpour. The anti-austerity rally appeared to be the largest in Athens since summer last year.
Analysts said that if the government pushed through the budget on Sunday as expected, eurozone finance ministers could agree at a meeting in Brussels on Monday to let Greece push back its fiscal targets by two years to 2016 and ease austerity's grip on growth.
That, in turn, will allow the European Central Bank to also take measures to give Athens some slack, and the debate can then turn to ways of easing Greece's debt load, which is expected to peak at more than 190% of gross domestic product in 2014.
Eurasia Group analyst Mujtaba Rahman said Samaras's government had shown stronger will than any of its predecessors in pushing through the belt-tightening.
But a key question remains over whether the Mediterranean state, having failed to implement numerous austerity plans in the past, would be able to overcome intransigence in the country's institutions and put Wednesday's package into force.
"There is political will. The question is whether the bureaucracy has the capacity to implement reforms," Rahman said. "Whether it can work is still an open question."