A tentative agreement with Greece was reached on Monday for a bailout program that includes "serious reforms" and aid, removing an immediate threat that Greece could collapse financially and leave the euro.
The deal was done nine hours after a self-imposed deadline passed.
If the talks had failed, Greece could have faced bankruptcy and a possible exit from the euro, the European single currency that the country has been a part of since 2002. No country has ever left the joint currency, which launched in 1999, and there is no mechanism in place for one to do so.
For three days of negotiations between Greece and its international creditors, Greek Prime Minister Alexis Tsipras held out for a better deal to sell to his reluctant legislature in Athens, even though financial collapse is getting closer by the day.
A breakthrough came in a meeting between Tsipras, German Chancellor Angela Merkel, French President Francois Hollande and EU president Donald Tusk. Details were not immediately available.
It also came after the threat of expulsion from the euro put intense pressure on Tsipras to swallow politically unpalatable austerity measures because his people overwhelmingly want to stay in the eurozone.
Greece has requested a three-year, €53.5 billion-euro financial package, but that number grew larger by the tens of billions as the negotiations dragged on and the leaders calculated how much Greece will need to stay solvent. The creditors are demanding tough austerity measures in exchange for Greece's third bailout in five years.
Early Monday, a Greek official said the key sticking points were the involvement of the International Monetary Fund in Greece's bailout program and a proposal that Greece set aside €50 billion worth of state-owned assets in a fund for eventual privatization.
The official, who spoke on condition of anonymity because he wasn't authoriSed to discuss the negotiations, said any agreement would provide quick help for Greek banks from the European Central Bank. Without it, they risk running out of money this week.
The negotiations began Saturday with a meeting of finance ministers. The heads of state convened mid-afternoon Sunday and were still negotiating at dawn Monday.
The deal on the table appeared to include commitments from Tsipras to push a drastic austerity program including pension, market and privatiSation reforms through parliament by Wednesday, and from the 18 other eurozone leaders to start talks on a new bailout program.
Sunday's four-page discussion paper put to eurozone leaders spoke of a potential "time-out from the euro area" for Greece if no agreement could be found.
It highlighted the increasing frustration of European leaders during five months of fruitless talks with Greece.
"The most important currency has been lost: that is trust and reliability," Merkel said.
Tsipras insisted his government was ready to clinch a deal.
"We owe that to the peoples of Europe who want Europe united and not divided," he said. "We can reach an agreement tonight if all parties want it."
Hollande insisted it was vital to keep Greece in the euro and said in the event of a departure, "it's Europe that would go backward. And that I do not want".
Greece has received two previous bailouts, totaling €240 billion euros, in return for deep spending cuts, tax increases and reforms from successive governments. Although the country's annual budget deficit has come down dramatically, Greece's debt burden has increased as the economy has shrunk by a quarter.
The Greek government has made getting some form of debt relief a priority and hopes that a comprehensive solution will involve European creditors at least agreeing to delayed repayments or lower interest rates.
Greek debt stands at around €320 billion euros - a staggering 180 percent or so of the country's annual gross domestic product. Few economists think that debt will ever be fully repaid. Last week, the International Monetary Fund said Greece's debt will need to be restructured.