Eurozone finance ministers reached an agreement tonight to extend heavily indebted Greece's financial rescue by four months, officials on both sides said.
"It's done. For four months," one said.
An agreement removes the immediate risk of Greece running out of money next month and possibly being forced out of the single currency area.
It provides a breathing space for the new leftist-led Greek government to try to negotiate longer-term debt relief with its official creditors.
The Greek government welcomed the deal, which a government official said gave Greece time to negotiate a "new deal".
"Greece has turned a page," the official said, adding that the new government will present reforms for the interim period, with a priority for those where there is common ground with its eurozone partners, such as tackling tax evasion, corruption and dealing with the humanitarian crisis.
"We have avoided recessionary measures," the official said.
Greek finance Minister Yanis Varoufakis said the agreement is the first step, but added it has not solved the problem of the fiscal gap.
Germany, Greece's biggest creditor, had demanded "significant improvements" in reform commitments by Greece before it would accept an extension of euro zone funding.
Eurozone officials said the accord required Greece to submit by Monday a letter to the Eurogroup listing all the policy measures it planned to take during the remainder of the bailout period, to ensure they complied with conditions.
Officials said an outline deal was reached in preparatory talks involving the Greek and German finance ministers, as well as the managing director of the IMF.
It was then agreed by the full 19-member Eurogroup, ending weeks of uncertainty.
With the €240bn EU/IMF bailout programme due to expire in little more than a week, Greek Prime Minister Alexis Tsipras voiced confidence of an agreement despite the objections to the request made in a letter to Dijsselbloem.
"I feel certain that the Greek letter for a six-month extension of the loan agreement with the conditionalities that accompany it will be accepted," Mr Tsipras said in a statement before the crucial Brussels meeting.
Officials said Greece's partners requested the shorter period.
A report by German magazine Der Spiegel that the European Central Bank was making contingency plans for a possible Greek exit from the currency area if the talks fail, on which the ECB declined comment, highlighted the high stakes.
German Chancellor Angela Merkel, speaking after talks in Paris, said all EU partners wanted to keep Greece in the euro but added: "There is a need for significant improvements in the substance of what is being discussed so that we can vote on it in the German Bundestag, for example next week."
The Greeks won sympathy from Italian Prime Minister Matteo Renzi.
"I believe that the principle of doing reforms in exchange for more time is just and correct," he said after a meeting of his government in Rome.
After preliminary talks with Mr Varoufakis, German Finance Minister Wolfgang Schaeuble and International Monetary Fund chief Christine Lagarde, Eurogroup chairman Jeroen Dijsselbloem said there was "reason for some optimism" but the search for agreement remained very difficult.
Finance ministers arriving from other euro zone states lined up to insist on more guarantees for creditors that Greece will fulfil the bailout's strict conditions on budget discipline and economic reforms to win their agreement.
Greece is determined to loosen austerity to revive its economy.
Mr Tsipras had a long telephone call with Ms Merkel on yesterday and has spoken repeatedly to the leaders of France and Italy in the search for a solution that allows his radical government to fulfil election promises and hold its head high.
"Greece has done everything possible so that we can arrive at a mutually beneficial solution, based on the principle of double respect: respect both to the principle of EU rules and to the electoral result of member states," he said.
Greece could run out of money by the end of March without new external funds, people familiar with the figures say, driving it nearer to the eurozone exit.
Eurozone officials said Greece's track record and the combative behaviour of its new leaders have undermined their confidence in whether Athens will deliver what it agrees to in talks with the other countries sharing the euro.