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.

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 (RM363 billion), Greece's 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 new rescue for Athens is the country's third since 2010 and came after a bitter six-month struggle following Tsipras's election in January that put Greece's membership of the eurozone in the balance.

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 single currency.

"Grexit has gone," European Commission President Jean-Claude Juncker told AFP, ruling out the threat of Greece leaving the single currency, which could potentially destablise not only the euro but the world economy.

Tsipras insisted the deal was good for Greece despite the fact that the harsh terms were near identical to those rejected by Greeks in a referendum just one week ago.

"We fought a righteous battle to the end," a smiling Tsipras said as he left the talks, adding that despite the deal's harshness the "great majority of Greek people will support this effort."

Asian markets rose on news of the debt deal, after a torrid few weeks while traders waited for an accord.


'Long, difficult road'

The austerity-pushing German Chancellor Angela Merkel, Europe's most powerful leader, said the situation for Athens however remained daunting, with success not guaranteed.

"The road will be long, and judging by the negotiations tonight, difficult," Merkel told reporters.

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.

Athens will now have to rush through new tough reform laws by Wednesday, according to the document agreed on by Tsipras and his eurozone counterparts.

Greece has to introduce harsh conditions on labour reform and pensions, VAT and taxes, and measures on privatisation, it added.

Under the agreement it will also park assets for privatisation worth up to 50 billion euros ($56 billion) in a special fund. The money in that fund will then be used to recapitalise Greece's cash-starved banks.

Greece applied last week for a third programme after its previous bailout expired on June 30, leaving it without international financial assistance for the first time in years.

Athens had infuriated its creditors -- the European Commission, ECB and IMF -- with its actions, including the surprise referendum on terms offered by the three institutions.

The Greek parliament approved new reform plans drawn up by the government in the early hours of Saturday, despite them being similar to those rejected by Greeks in the plebiscite.

A Greek government official had earlier said the terms offered by eurozone leaders were "very bad", amid concerns they would effectively take control of much of Greek finances away from Athens.


'Franco-German rift'

Tsipras was elected in January vowing to end five years of austerity tied to two previous bailouts since 2010.

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.

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, but the idea was dropped from the final document amid opposition from France.

The crisis has exposed tensions between the eurozone's two biggest powers with pro-austerity Berlin going head-to-head with Paris, which has been supportive of Greece during the crisis.

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 thousands of kilometres (miles) away in Brussels.

The ECB is providing emergency liquidity to keep Greek banks afloat but has frozen the limit, with any change dependent on a debt deal.