BRUSSELS (AP) — After more than 12 hours of talks, the countries that use the euro reached an agreement early Tuesday to hand Greece (euro) 130 billion ($170 billion) in additional bailout loans to save it from a potentially disastrous default next month.

The deal is expected to bring Greece’s debt down to 120.5 percent of gross domestic product by 2020 — that’s around the maximum that the International Monetary Fund and the eurozone consider sustainable.

The euro surged as the news of a deal broke early Tuesday. The accord should take some pressure off the 17-country currency union that has been battling a serious debt crisis for two years.

Without the deal, Greece was facing a potentially calamitous default next month and possibly being forced from the eurozone. The talks stretched into the early hours of Tuesday as ministers wrangled over how to cut Greece’s debt to a level that it could eventually pay back while not raising their own commitments.

In the end, the country’s private creditors were asked to take substantially more losses on their holdings than previously anticipated, cutting Greece’s debt by an estimated (euro) 107 billion.

“It’s no exaggeration to say that today is a historic day for the Greek economy,” said Greek Premier Lucas Papademos, who rushed to the meeting to lend weight to his country’s pleas for help.

Jean-Claude Juncker, the prime minister of Luxembourg who also chairs the meetings of eurozone finance ministers, said Greece’s private investors — mostly banks and investment funds — have been asked to take a face value loss of 53.5 percent on their bonds.

On top of that, Greece’s public creditors — central banks and the eurozone countries — also agreed to give Greece a break on its debt.

The eurozone countries will cut the interest that Greece has to pay for its first package of bailout loans to 1.5 percentage points over market rates from between 2 percentage points to 3 percentage points currently, cutting both its debt load and limiting the need for new rescue loans.

At the same time, the European Central Bank and the national central banks in the 17 countries that use the euro will also forego profits on their Greek debt holdings, again reducing the costs for Greece.

EU economic affairs commissioner Olli Rehn says Greece’s new compliance with the terms of a new bailout will be ensured by a separate account containing enough money service its debt for three months.

That close monitoring was demanded by some members of the eurozone who are frustrated that Greece has not always enacted painful reforms and budget cuts on time.