The Greek parliament has approved the draft details a third bailout in five years after talks that lasted through the night and well into the morning.
The new deal involves tax rises and spending cuts in return for a bailout of about €85 billion ($95 billion).
Greece’s 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, August 14.
The deal received 222 votes for, 64 against and 11 abstentions.
There were 31 “No” votes from Syriza members, and 11 abstentions – the biggest rebellion within Alexis Tsipras’ party so far. The rebels represented almost a third of all Syriza’s members of parliament.
According to the Greek media, the prime minister will ask for a confidence vote before parliament in the next week.
Voting started just after 09:30 local time, 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 August 20, when it must repay about €3.2 billion to the European Central Bank (ECB).
If Greece 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 Alexis Tsipras’ most vocal critics within his own party was his former ally, parliamentary speaker Zoe Konstantopoulou.
Zoe Konstantopoulou said she could not support the deal, and faced calls from Alexis 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 member, Panagiotis Lafazanis, told Alexis Tsipras: “I feel ashamed for you. We no longer have a democracy, but a eurozone dictatorship.”
Alexis Tsipras told the parliament: “I have my conscience clear that it is the best we could achieve under the current balance of power in Europe, under conditions of economic and financial asphyxiation imposed upon us.”
Rebels have insisted the government should make good on its electoral promise to reverse spending cuts and tax rises.
In two prior votes on bailout reforms, rebels had refused to approve tax increases, pension cuts and market reforms.