Eurozone leaders struck a deal Monday on plans for a bailout to prevent debt-stricken Greece from crashing out of the euro after Athens bowed to draconian demands for reform.
After gruelling 17-hour talks during which the future of the European project hung in the balance, leftist Greek Prime Minister Alexis Tsipras accepted terms set by his mistrustful partners.
The deal requires him to push through a raft of market-oriented laws by Wednesday as a sign of good faith, scrutinised by the International Monetary Fund (IMF) for complicance.
Only then will the 18 other eurozone leaders start negotiations over what Greece will get in return: a three-year bailout worth up to 86 billion euros ($96 billion), its third rescue programme in five years.
"EuroSummit has unanimously reached agreement," EU President Donald Tusk said.
"All ready to go for ESM (eurozone bailout fund the European Stability Mechanism) programme for Greece with serious reforms and financial support."
The last-ditch deal is aimed at keeping Greece's economy afloat amid fears its cash-starved banks were about to finally run dry and trigger its exit from the single currency.
"Grexit has gone," European Commission President Jean-Claude Juncker told AFP after the talks, ruling out the threat of a departure from the euro which could have potentially destablised the global economy.
A weary Tsipras insisted the deal was good for Greece, even though analysts say the terms are in some respects tougher than those Greek voters had rejected on his recommendation in a referendum just one week ago.
"We fought a righteous battle to the end," Tsipras said.
The deal, Tsipras argued, includes help to ease Greece's huge burden of debt and revive its crippled banking system.
"The great majority of Greek people will support this effort," he added.
European and Asian markets rose, although the euro ran out of steam as cautious dealers awaited clearer details of the accord.
- Tough sell at home -
But Tsipras now faces a tough task selling the deal to the Greek people, parliament and his radical Syriza party, which shot to power in January on the back of promises to end five years of bitter austerity under two previous bailouts.
Faced with a deeply distrustful eurozone after six months of tense meetings, the 40-year-old Tsipras had to agree to demands that critics say rob Greece of financial indepdendence.
"The road will be long, and judging by the negotiations tonight, difficult," said German Chancellor Angela Merkel, Europe's leading champion of austerity.
Europe's first step will be to push the deal through several national parliaments, many in countries that are loath to afford Greece more help.
Germany's Bundestag is likely to vote on Friday, provided the Greek parliament rushes through four new reform laws by Wednesday.
Greece has to make sweeping changes to labour laws, pensions, VAT and taxes, according to the document, which seeks to regulate some of the country's tiniest financial details.
Despite strong opposition, Tsipras also yielded to a plan to park assets for privatisation worth up to 50 billion euros ($56 billion) in a special fund.
Some 25 billion euros of the money in that fund will then be used to recapitalise Greece's cash-starved banks, which have been badly damaged by two weeks of capital controls.
Further humiliations come in the form of a return of officials from the widely loathed "Troika" of Greece's creditors -- the European Commission, European Central (ECB) and IMF.
There is also a pledge to reverse laws brought in by the Syriza government since the election that run counter to Greece's earlier bailout arrangements in 2010 and 2012.
The deal contained little mention of relieving a Greek debt mountain worth 180 percent of GDP -- a step recommended by the IMF -- beyond a vague mention that it should be considered later.
- #ThisIsACoup -
The deal triggered angry reactions on social media across Europe, where the Twitter hashtag #ThisIsACoup trended.
The marathon talks also exposed tensions at the heart of the the post-war European project, especially between hawkish Berlin and softer Paris, which has been Greece's biggest supporter during the crisis.
French President Francois Hollande hailed Tsipras for making a "courageous choice" in agreeing to the reforms despite the political risks at home.
France also led efforts to have a clause on a German-backed idea for a "temporary Grexit" option dropped from the leaders statement. Its appearance in an earlier draft marked the first time the idea of a euro member leaving the currency had appeared in black and white.
The eurozone must now unite to tackle the immediate problem of finding funds to keep Greece afloat, as the bailout could take months to finalise.
The ECB has kept Greek banks afloat with emergency liquidity, but has refused to provide extra funds.
Banks are closed and many cash machines are running dry despite a 60-euro-a-day ATM limit.
The ECB's governing council was set to hold a telephone conference on its emergency liquidity assistance for Greece in the afternoon, sources told AFP, with hopes that it might free up more cash.
Tusk said eurozone finance ministers would "as a matter of urgency" at a meeting later Monday consider bridge funding to get Greece through coming weeks during which it faces several huge debt payments to the ECB and other creditors.