Eurozone leaders have reached an agreement after marathon talks over a third bailout for Greece, officials say.
EU President Donald Tusk said the agreement was unanimous. He tweeted that a bailout programme was "all ready to go" for Greece, "with serious reforms and financial support".
Amid one of the worst crises in the EU's history, the head of the European Commission said the risk of Greece leaving the eurozone had been averted.
Greece will now have to pass reforms demanded by the eurozone by the middle of the week.
These include measures to streamline pensions, raise tax revenue and liberalise the labour market.
Prime Minister Alexis Tsipras said that after a "tough battle", Greece had secured a "growth package" of €35 billion, and won debt restructuring.
EuroSummit has unanimously reached agreement. All ready to go for ESM programme for #Greece with serious reforms & financial support— Donald Tusk (@eucopresident) July 13, 2015
Analysts say Greece will now have to swallow a bitter pill.
Critics have described the deal as "very bad", saying the Eurozone is effectively taking over financial control.
The leaders hammered out the proposal on the sidelines of an emergency summit of the 19 countries that use the euro.
The leaders had been meeting to thrash out a bailout deal, after Athens received an ultimatum to accept harsh reforms or be cast out of the single currency.
"There will not be a 'Grexit'," said European Commission head Jean-Claude Juncker, referring to the fear that Greece would have to leave the euro.
"The deal is difficult but we averted the pursuit to move state assets abroad," Mr Tsipras said. "We averted the plan for a financial strangulation and for the collapse of the banking system."
Jeroen Dijsselbloem, the head of the eurozone group of finance ministers, said the agreement included a €50 billion Greece-based fund that will privatise or manage Greek assets.
Out of that €50 billion, €25 billion would be used to recapitalise Greek banks, he said.
Parliaments in several eurozone states have to approve any new bailout.
"The road will be long, and judging by the negotiations tonight, difficult," German Chancellor Angela Merkel said on Monday morning.
French President Francois Hollande said the agreement had allowed Europe to "preserve integrity and solidarity".
"We also had to show that Europe is capable of solving a crisis that has menaced the eurozone for several years," he said.
Eurozone leaders had been meeting in Brussels for about 17 hours, with talks continuing through the night.
During the night, reports emerged that Greece was holding out over the proposed role of the International Monetary Fund (IMF) in a new programme, and over the fund to hold Greek assets.
But a Greek government official said they still had issues with the proposal, including the International Monetary Fund role and the requirement to put aside assets worth up to €50 billion for privatisation.
He said Greece had been negotiating with a gun to its head.
The document of measures was the result of two days of fraught talks among eurozone finance ministers.
One Greek government official called the proposals "very bad".
Another unnamed official said some of the proposals appeared designed to "humiliate" Greek Prime Minister Alexis Tsipras and his Syriza government.
The four-page document of draft proposals put forward by eurozone finance ministers includes:
Arriving for the meeting, France's President Francois Hollande dismissed any suggestion of a "time-out" for Greece.
"There is no temporary Grexit, there is a Grexit or there is not a Grexit," he said, adding that he would "do everything to find a deal tonight".
Mr Tsipras was also upbeat, telling reporters: "I'm here ready for an honest compromise... we can reach an agreement tonight if all parties want it."
But German Chancellor Angela Merkel said "the most important currency has been lost... trust and reliability" in the last few months of negotiations with Greece, and there would be "no agreement at any price".
"We have to make sure the pros outweigh the cons - for Greece's future, for the entire eurozone and the principles of our collaboration," she said.
The head of the European Parliament, Martin Schulz, said a deal was absolutely vital to the future of Europe.
"The alternative will be that over the next few years we are going to find ourselves in a catastrophic state of affairs as far as Greece is concerned," he told a news conference in Brussels.
Time running out
The Greek government earlier this week set out a new list of austerity measures to try to secure the bailout. They included many measures that had been rejected by the Greek people in a referendum a week ago.
Greek banks have been closed for two weeks, with withdrawals at cash machines limited to €60 per day.
The economy has been put under increasing strain, with some businesses closing and other struggling to pay suppliers.
Despite this, the proposals won the overwhelming backing of Greece's parliament in the early hours of Saturday.
Technical experts from Greece's creditors - the European Commission, the European Central Bank and the International Monetary Fund - also said the proposals were a basis for negotiations.
However, time is running out to prevent Greece's economic collapse.
There is little money left in the banks and public sector workers are due to be paid this week.
Greece fell into arrears on an IMF repayment on 20 June and faces a €3bn payment to the European Central Bank on 20 July.
It has already received two bailouts totalling €240bn since 2010.