Greece reached a desperately-needed bailout deal with the eurozone on Monday after marathon overnight talks, in a historic agreement to prevent the country crashing out of the European single currency.
The country's leftist Prime Minister Alexis Tsipras agreed to tough reforms after 17 hours of gruelling negotiations in return for a three-year bailout worth up to 86 billion euros ($96 billion), Greece's third rescue programme in five years.
EU President Donald Tusk announced the deal for debt-stricken Greece on Twitter, ending a bitter six-month struggle between Tsipras's anti-austerity government in Athens and the rest of the eurozone.
"EuroSummit has unanimously reached agreement," former Polish premier Tusk said. "All ready to go for ESM programme for Greece with serious reforms and financial support."
Greece applied last week for a third programme from the eurozone's bailout fund, the European Stability Mechanism, after its previous bailout expired on June 30, leaving it without international financial assistance for the first time in years.
Greek banks have been closed for nearly two weeks and there were fears they were about to run dry due to a lack of extra funding by the European Central Bank, meaning Athens would have had to print its own currency and effectively leave the euro.
Athens had infuriated its creditors with actions including a surprise referendum on July 5 in which Greeks overwhelmingly rejected previous bailout terms offered by its creditors.
- 'No deal at any price' -
The full terms of the new deal were not immediately available but they looked set to be even tougher than those originally offered to Greece.
A Greek government official had earlier said the terms drafted on Sunday by the euro finance ministers were "very bad", amid concerns they would effectively take control of much of Greek finances away from Athens.
Under terms drawn up by eurozone finance ministers at the weekend, Athens would now have to push through new even tougher laws by Wednesday, Finnish Finance Minister Alex Stubb said.
Athens would have to introduce harsh conditions on labour reform and pensions, VAT and taxes, and measures on privatisation, he added.
Key sticking points included the involvement of the IMF and a call for Greece to park assets of up to 50 billion euros ($56 billion) in a fund in Luxembourg for privatisation.
Arriving for what was billed as a last-chance summit Sunday, Merkel said there would be "no agreement at any price", complaining of a loss of trust in Athens.
Tsipras, who was elected in January vowing to end five years of austerity tied to two previous bailouts since 2010, had said a deal was "possible" if all sides were willing.
The 40-year-old has become a standard-bearer for leftist parties across the continent who say the austerity policies championed by Brussels undercut growth and cause massive unemployment.
The Greek parliament approved Greece's new reform plans on Saturday, despite them being similar to those rejected by Greeks in the referendum.
- Franco-German rift -
For the first time in the history of the single currency, the Eurogroup even proposed a temporary Greek exit from the euro, an idea first floated by Germany, although that proposal appeared to have been dropped.
Other measures include letting the "troika" of creditors back on the ground in Athens after they were expelled by Tsipras's government, and securing creditors' approval for any legislation affecting issues covered by the bailout.
The crisis has exposed tensions between the eurozone's two biggest powers with pro-austerity Germany going head-to-head with France, which has been supportive of Greece during the crisis.
French President Francois Hollande said Paris would do "everything" to keep Greece in the euro and ruled out the "temporary Grexit" proposal.
Five years have elapsed since the Greek debt drama began, but the latest instalment has opened deeper-than-ever rifts in the European single currency, the heart of the post-war dream of a politically unified Europe.
In Greece, there is growing alarm at capital controls that have closed banks and rationed cash at ATMs for nearly two weeks, leading to fears that food and medicine will soon run short.
"We don't sleep, everybody's worried," a Greek pensioner said, watching with concern the events taking place in Brussels several thousand kilometres (miles) away.
The ECB is providing emergency liquidity to keep Greek banks afloat but has frozen the limit, with fears that failure to reach a deal could cause it to shut off the taps completely.