At a glance: European debt deal
After much back-and-forth for the past year, Europe's leaders have agreed on a comprehensive solution to the Greek debt crisis.
Greece has more than 300bn euros (£264bn) of debt - over 140% of its output - which few think it would have been able to pay back.
The European Union and the International Monetary Fund agreed to a 110bn-euro bailout last year.
But that was not enough - with the Irish Republic and Portugal bailed out afterwards and fears of contagion spreading to larger economies like Spain and Italy.
Which led to this week's extraordinary summit in which the leaders of the eurozone plotted a deal to prevent more crises.
So what was the deal?
The new bailout package is worth 109bn euros and will be channelled through the primary European rescue fund, called the European Financial Stability Facility.
This was created in May 2010 after the first Greek aid package - but the powers of the fund have now been greatly expanded.
Now, the fund can act on a precautionary basis - in advance of a crisis rather than responding to it.
It can also lend directly to banks which run out of capital rather than to governments.
Crucially, the fund can also buy debt in the secondary market - something that the European Central Bank (ECB) had been wary of.
Now, to do so, the fund can only do so in "exceptional financial market circumstances" on the recommendation from the ECB.
The eurozone will give its 109bn euros of new loans to Greece at longer terms - from 7.5 years now to between 15 and 30 years.
The interest rates on Greece's debt will drop significantly to around 3.5%.
The rates on Europe's rescue loans to the Irish Republic and Portugal will also drop by 1-2%.
In addition, private bondholders are expected to make an additional 37bn euros by extending the amount of time that Greece has to pay back its debt.
This is a crucial component. Germany had insisted that bondholders bear some of the pain, but the central bank and others had resisted for fear of riling the ratings agencies.
This 37bn euros of contributions involves banks swapping their Greek debt for longer-term maturities.
And the eurozone wants to buy back 12.6bn euros of Greek debt already out there at a reduced price - taking the total private contribution to 50bn euros.
All in all, creditors are being asked to accept a 21% loss on the debt they hold.
The reaction of the financial markets is key.
Because bondholders will be asked to take a loss, this could be considered a selective default by ratings agencies.
In that case - banks (and the ECB) would be forced overnight to recognise in their financial accounts billions of euros in losses on Greek debts they own.
Fitch has already said it will declare Greece in default on its long-term debt once the bond swaps occur.
But the eurozone has tried to avoid panic by making it clear that its rescue fund can recapitalise banks in Europe as it sees fit.