Greece's parliament has backed draft terms for a third bailout in five years after talks that lasted through the night and well into the morning.
The proposed deal involves tax rises and spending cuts in return for a bailout of about €85bn (£61bn, $95bn).
Prime Minister Alexis Tsipras also survived a significant rebellion within his own Syriza party.
The terms of the bailout will be discussed by eurozone finance ministers later on Friday.
There were 222 votes for the deal, 64 against and 11 abstentions. But there were 31 "No" votes from Syriza members, and 11 abstentions - the biggest rebellion within Mr Tsipras' government so far.
Reports in Greece said he will ask for a confidence vote before parliament in the next week.
The debate itself was preceded by hours of often angry exchanges in parliament.
Voting started just after 09:30 local time (06:30 GMT), more than six hours after the main debate began. The debate itself had been delayed by procedural issues.
Members of parliament had to agree on the terms so that eurozone ministers could endorse the draft deal.
Greece faces an urgent deadline on 20 August, when it must repay about €3.2bn to the European Central Bank (ECB).
If it had failed to agree on new terms for a bailout, the ECB is likely to have stopped giving emergency funds to Greek banks.
One of Mr Tsipras' most vocal critics within his own party was his former ally, parliamentary speaker Zoe Konstantopoulou.
She said she could not support the deal, and faced calls from Mr Tsipras to hurry her handling of the bill. Instead, she took time to raise several concerns, delaying the timing of the debate - to the prime minister's visible frustration.
Another Syriza MP, Panagiotis Lafazanis, told Mr Tsipras: "I feel ashamed for you. We no longer have a democracy, but a eurozone dictatorship."
In two prior votes on bailout reforms, Mr Tsipras had faced rebellions from his own party, with more than 30 of Syriza's 149 MPs refusing to approve the previous tax increases, pension cuts and market reforms.
Rebels have insisted the government should make good on its electoral promise to reverse spending cuts and tax rises.
The government has defended the controversial new programme as tough but essential if the country is to avoid financial collapse.
Source: BBC