Greece enacted billions of euros in spending cuts and fresh austerity measures last night in a volatile parliamentary vote aimed at avoiding default on its national debt and keeping the eurozone intact, despite some of the worst rioting and political violence witnessed in the country in years.

More than 40 buildings were set ablaze in an orgy of looting that left scores injured as protesters vented their anger at the caretaker government and parliament's ordering of a further €3.3bn of savings by slashing wages and pensions and laying off public sector workers.

Don't let big tech control what news you see. Get more stories like this in your inbox, every day.

In return, Greece is to receive a second eurozone bailout in two years worth €130bn in addition to a €100bn writedown of debt by the bankrupt country's private creditors.

There was turmoil inside the parliament, too. MPs voted 199-74 in favour of the cutbacks, despite strong dissent among the two main coalition members.

A total of 37 politicians from the majority Socialists and conservative New Democracy party either voted against the party line or abstained. A further six voted against sections of the legislation. After the vote, the government announced that those 43 ministers had been expelled.

But the scenes of mayhem on the streets of Athens and all across the country leave big questions unresolved regarding Greece's capacity to stick with the savage austerity. The country is in its fifth year of recession and has little prospect of halting a steep decline in living standards.

With eurozone leaders declaring it was time for Greece to put up or shut up and that Athens' promises could no longer be believed, Greece's two main parties and the caretaker prime minister invoked apocalyptic scenarios for the country if the cuts were not supported.

Meanwhile street battles between police firing rounds of teargas and demonstrators hurling firebombs and marble slabs left Syntagma square, the plaza in front of the parliament building, resembling a war zone.

Rubbish bins burned and plumes of smoke and asphyxiating clouds of toxic chemicals filled the air.

The explosions were so loud, they could be heard inside parliament and the teargas drifting across square reached the debating chamber. The buildings that were set on fire included cinemas, banks and a number of shops, and Greek television reported that dozens of citizens and at least 40 police officers had been injured.

Under a sea of banners denouncing further wage, pension and job cuts, tens of thousands of protesters chanted against "the occupation" of the country by foreign lenders keeping Greece afloat.

"The rebellion has begun," the veteran leftwinger Manolis Glezos told TV reporters. "These measures will never pass. They are a breach of our democracy," he said, holding a mask to his face against the fumes.

The prime minister, Lukas Papademos, warned before the vote that wages and pensions would go unpaid, hospitals and schools would be devoid of funding, banks would collapse and people's savings would be lost if the 300 MPs rejected the terms set for receipt of a €130bn bailout.

Without the bailout – the second in two years – Greece would have been insolvent and would be forced to default on its debt next month when it needs to redeem €14.5bn of loans.

The punishment for those who failed to back the bill was swift and decisive. The conservative New Democracy party said it had expelled 21 out of its total 83 deputies. The Socialist PASOK party expelled about 20 of its 153 MPs.

But the finance minister, Evangelos Venizelos, had warned: "If the law is not passed, the country will go bankrupt."

George Papandreou, the former socialist prime minister felled by the crisis last year, declared that Greece was embroiled in war it had to win. Antonis Samaras, the centre-right leader tipped to be prime minister after elections expected in April, also rallied his MPs behind the deal despite having resisted key details for weeks.

With trust between Athens and its eurozone creditors, led by Germany, at an all-time low, the Greek government was told the time for pledges had run out. "Greece's promises are no longer enough for us," said Wolfgang Schäuble, Germany's finance minister, who also spoke of the possibility of Greece leaving the euro.

Following a day of high drama inside and outside parliament in Athens, the Greek coalition leaders now have to deliver some signed undertakings to Brussels that the measures decided last night are irreversible and will be implemented no matter who wins an election that is expected in April.

Eurozone finance ministers are then to agree to the bailout on Wednesday provided Greece meets its end of the bargain. Berlin is insisting most of the money is held in a separate account and is used purely to service Greece's debt. EU ministerial sources said that account could hold up to 70% of the bailout funds. By guaranteeing Greece's creditors are repaid, there would be no default.

Helena Smith is the Guardian's correspondent in Greece, Turkey and Cyprus