Europe granted Greece a crucial four-month extension to its massive debt bailout, offering precious breathing space, but at the cost of huge concessions including a commitment to spell out reforms within two days.
The 19 eurozone finance ministers reached the hard-won deal at tense talks pitting Greece against an angry Germany, suspicious that the new radical leftist government in Athens was looking to ditch its austerity obligations.
The deal is a tough climb down for popular Greek premier Alexis Tsipras, who swept to power in January on a pledge to tear-up Greek's hated bailout programme, and he will have to persuade Athens that this was the best deal possible.
"The meeting was intense because it was about building trust between us," said Eurogroup head Jeroen Dijsselbloem, after the talks ended with a two-page statement setting out the tough conditions Athens will have to fulfil.
"This trust will be on the basis of the agreements and changes in the agreements which will have to be worked out," he said.
In exchange for the extension, Greece agreed it will submit a list of economic and other reforms by Monday to the hated "troika" of creditors for review, and to see if they go far enough.
On Tuesday, they will report back to Greece and decide whether to proceed with Friday's agreement, with the chance that the compromise could be scrapped if officials are left unsatisfied.
Greek Finance Minister Yanis Varoufakis said the deal marked a new era for Athens and its relationship with the European Union, after two painful bailouts put together at the height of the debt crisis to save the euro.
Athens claimed the rescues and the austerity measures it had to follow since its first 2010 bailout had wrecked the Greek economy, making it impossible to manage its mountain of debt.
"Today was a pivotal moment because Greece for five years now has been lonely, isolated in the Eurogroup. Today that isolation has broken," Varoufakis said.
However, he warned: "If the list of reforms is not agreed, this agreement is dead."
Markets reacted positively to the deal, with the Dow and S&P 500 surging to fresh records on Wall Street as fears of a catastrophic exit by Greece from the euro receded.
Two previous rounds of talks failed in bitter acrimony amid Greek accusations that Berlin and other hardline member states were sabotaging a deal.
- 'Rendez-vous with reality' -
"Everything we do is in my opinion for the interest of Greece," said German Finance Minister Wolfgang Schaeuble, a conservative and Greece's harshest critic who had initially rejected Athens' request for a loan extension on Thursday.
"Being in government is a rendez-vous with reality. Quite frequently it is not as nice as the dream," Schaeuble added.
The specifics of the deal will be a hard read in Athens, especially for supporters of the ruling Syriza party who had hoped for the end of the austerity and creditor oversight so loathed by the Greeks.
"The Greeks left behind the memorandum and are becoming the co-author of reforms and of their destiny," Varoufakis said, referring to the stringent cost-cutting measures and reforms attached to the original bailout.
But much-criticised oversight by Greece's international lenders will continue and the government made a firm commitment to freeze anti-austerity reforms so as to have them first vetted by the eurozone.
At stake for Greece is a crucial financial lifeline that would have evaporated on February 28 without a deal, including crucial liquidity from the European Central Bank that is helping keep Greek banks afloat.
If Athens sticks to its commitments, it stands to receive up to 7.2 billion euros in funds still left in the EU portion of its 240-billion-euro bailout ($273 million).
"Four months is the appropriate delay in terms of financing and future challenges," Dijsselbloem said.
Up to the very end, the deal with Greece seemed uncertain, with a possibly chaotic exit from the eurozone always a danger.
Dijsselbloem worked overtime Friday to keep the talks on track as Germany insisted Greece stick with the austerity commitments included in its existing bailout programme.
With distrust for Greece widespread among ministers, it was a lengthy phone call between premier Tsipras and German Chancellor Angela Merkel late Thursday which appeared to make Friday's breakthrough possible.
European officials said the stand-off had come down to a clash of personalities with Schaeuble furious at the negotiating style of the casual Varoufakis, who, in a change, remained markedly sombre on Friday.
After the talks, a key European official said the Schaeuble-Varoufakis relationship was still fraught.
"The trust just isn't there. (This time) Varoufakis kept a very low-profile: no waves," the source said.