BRUSSELS (AP) -- Greece won a second massive financial bailout in the early hours of Tuesday morning when its partners in the 17-country eurozone finally stitched together a euro130 billion ($170 billion) rescue, meant to avoid a potentially disastrous default and secure the euro currency.
But the patchwork of measures, including the implementation of more austerity in Greece and approval by skeptical German and Dutch Parliaments, required to give the rescue even a chance of success mean that it's unlikely to be the end of the continent's debt crisis.
Markets responded cautiously to the long-awaited deal, though the euro managed to eke out some gains as the fear of a disorderly Greek debt default within a month diminished.
The finance ministers from Greece and the other 16 countries that use the euro as their currency wrangled until the early morning hours over the details of the rescue, squeezing last-minute concessions out of private holders of Greek debt.
The eurozone and the International Monetary Fund, which will be providing the money for the new bailout, hope the new program will eventually put Greece back into a position where it can survive without external support and secure its place in the euro currency union.
The accord, which had been months in the making, seeks to reduce Greece's massive debts on all fronts, with both private and official creditors going beyond what they had said was possible in the past.
On top of the new rescue loans, Athens will also ask banks and other investment funds to forgive it some euro107 billion ($142 billion) in debt, while the European Central Bank and national central banks in the eurozone will forgo profits on their holdings.
But despite those unprecedented efforts, it was clear that Greece, which kicked off Europe's debt crisis two years ago, was at the very best starting on a long and painful road to recovery. At the worst, the new program would push the country even deeper into recession and see it default on its debts further down the line.
"It's not an easy (program), it's an ambitious one," said Christine Lagarde, the head of the IMF, adding that there were significant risks that Greece's economy could not grow as much as its international creditors were hoping.
The eurozone - and Greece - had been under pressure to reach an accord quickly to prevent Athens from defaulting on a euro14.5 billion ($19.2 billion) bond payment on March 20. The fear is that an uncontrolled bankruptcy even of relatively small Greece could unleash market panic across the rest of the continent. That would further unsettle other struggling countries like Ireland, Portugal or the much bigger Italy or Spain.
Despite the promise of new rescue loans, which come on top of a euro110 billion ($146 billion) bailout granted in 2010, the other 16 euro countries made clear that their trust in Greece is running low. Before Athens will see any new funds, it has to put into practice a whole range of previously promised cuts and reforms.
More significantly, Greece will have to pass within the next two months a new law that gives paying off the country's debts legal priority over funding government services. In the meantime, Athens has to set up a kind of escrow account, managed separately from its main budget, that will at all times have to contain enough money to service its debts for the coming three months.
These requirements, together with tighter on-the-ground monitoring, are an unprecedented intrusion into the fiscal affairs of a sovereign state in Europe and could eventually see Greece being forced to pay interest on its debt before compensating teachers, doctors and other state employees.
Greek politicians nevertheless greeted the package as a turning point for their battered country.
"It's no exaggeration to say that today is a historic day for the Greek economy," said Greek Premier Lucas Papademos, who had rushed to the finance ministers' meeting to lend weight to his country's pleas for help.
The eurozone and the IMF said the deal is expected to bring Greece's debt down to 120.5 percent of gross domestic product by 2020 - around the maximum that they consider sustainable. At the moment, Greece's debt stands at more than 160 percent of GDP.
The euro spiked 0.5 percent to $1.3264 following the deal but stock markets in Europe were trading slightly lower, having enjoyed solid gains in the run-up to the meeting on the expectation that a deal would be secured.
Even some of the politicians who had pushed hardest for sticking close to the 120 percent target first set out in October conceded that it was questionable whether that level was indeed manageable for such a week economy as Greece.
"One can discuss at length the assumptions on which this (target) is based," German Finance Minister Wolfgang Schaeuble said after the meeting. "Because of that we decided to at least be sincere about the figures."
Ahead of the meeting, Greece's international creditors - the EU, the ECB and the IMF - warned that without new measures the debt would still remain close to 129 percent by the end of the decade even under its optimistic scenario. That shortfall persisted even though Athens had faced down violent protests to pass a massive new round of cuts and reforms through Parliament just last week.
So to reach a successful outcome, the finance ministers had to fight on many fronts.
The representatives of private holders of Greek debt had to agree to steeper losses than they had previously said was possible in a voluntary debt relief. The Institute of International Finance said that the bond swap could see Greece's debt reduced by euro107 billion immediately. On top of that, investors will be asked to give Athens 30 years to repay them, compared with just under 7 years. Average interest rates, meanwhile, would fall to 3.65 percent from around 4.8 percent.
Private investors weren't the only ones having to give ground.
The eurozone countries will reduce 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 countries that use the euro will forego profits on their Greek debt holdings, again reducing the costs for Greece.
"It's a very good accord in the sense that it is equitably divvied up," said French Finance Minister Francois Baroin. "The Greeks have made their efforts. The Europeans are playing their supporting role, in their role as creditors ... And the private sector part goes beyond" what could be expected.
But several hurdles remain before Greece will see any of the money or other benefits of the new program.
Apart from the implementation of more than 30 different savings and reform measures by Greece, the new bailout has to be debated by parliaments in several member states, including Germany, the Netherlands and Finland.
The IMF also still has to decide how much of the euro130 billion bill it is willing to stump up. Going into the meeting, the Washington-based fund had indicated that its contribution will be lower than the one-third of the total it has provided in previous bailouts.
The IMF's Lagarde said the fund's board would decide on its contribution in the second week of March.
"In doing so it will have in mind the overall program, but also additional matters such as the proper setting up of a decent firewall," Lagarde said with reference to Europe's current and future bailout funds.
At the moment, the overall ceiling for eurozone rescue loans has been set ateuro500 billion ($663 billion), much of which has already been committed to Ireland, Portugal and now Greece. Euro leaders will decide at their summit in early March whether that ceiling should be increased.
On top of that, it will also take some time to see how many private creditors will participate in the debt relief and how many of them will have to be forced to sign up through new legal clauses Greece plans to implement. Some analysts fear that imposing losses on even some bondholders may destabilize markets.
Perhaps most crucially, however, may be new national elections in Greece scheduled for April, which could upend the political landscape in the country. The leaders of the two main parties have committed to the cuts and reform program, but anti-bailout parties have been gaining in the polls.
Associated Press writers Derek Gatopoulos in Athens, Greece, and Don Melvin in Brussels contributed to this report.