Eurozone ministers have agreed to cut Greece's debts by a further 40bn euros ($51bn; £32bn), as well as releasing 44bn in bailout money and aid.

A few weeks earlier, they had also agreed to give the government in Athens two more years to cut its overspending.

That decision came as Greece's parliament approved a budget for 2013 that involves 9.4bn euros of spending cuts, a budget that triggered mass public protests in Athens.

The delay in releasing the latest bailout money was largely due to wrangling between eurozone lenders and the International Monetary Fund (IMF) over whether and by how much to cut Greece's debt, which will inevitably grow even more if Athens continues overspending for longer than previously planned.

Why is Greece in trouble?

Greece was living beyond its means even before it joined the euro. After it adopted the single currency, public spending soared.

Public sector wages, for example, rose 50% between 1999 and 2007 - far faster than in most other eurozone countries. The government also ran up big debts paying for the 2004 Athens Olympics.

And while money flowed out of the government's coffers, its income was hit by widespread tax evasion. So, after years of overspending, its budget deficit - the difference between spending and income - spiralled out of control.

Moreover, much of the borrowing was concealed, as successive Greek governments sought to meet the 3%-of-GDP cap on borrowing that is required of members of the euro.

When the global financial downturn hit - and Greece's hidden borrowings came to light - the country was ill-prepared to cope.

Debt levels reached the point where the country was no longer able to repay its loans, and was forced to ask for help from its European partners and the IMF in the form of massive loans.

In the short term, however, the conditions attached to these loans have compounded Greece's woes.

What has been done to help Greece?

In short, a lot.

In May 2010, the European Union and IMF provided 110bn euros ($140bn: £88bn) of bailout loans to Greece to help the government pay its creditors.

However, it soon became apparent that this would not be enough, so a second, 130bn-euro bailout was agreed earlier this year.

As well as these two loans, which are made in stages, the vast majority of Greece's private-sector creditors agreed to write off about three-quarters of the debts owed to them by Athens. They also agreed to replace existing loans with new loans at a lower rate of interest.

In the latest agreement, Greece's lenders have found ways to shave an extra 40bn euros off Greece's debtload.

However, in return for all this help, the EU and IMF insisted that Greece embark on a major austerity drive involving drastic spending cuts, tax rises, and labour market and pension reforms.

These have had a devastating effect on Greece's already weak economic recovery. The latest Greek budget predicts that the economy will shrink by 6.5% this year and by a further 4.5% in 2013. Greece has already been in recession for four years, and its economy is projected to have shrunk by a fifth between 2008 and the end of this year.

Without economic growth, the Greek government cannot boost its own tax revenues and so has to rely on aid to pay its loans.

Many commentators believe that even the combined 240bn euros of loans and the debt write-off will not be enough.

Crisis jargon buster Use the dropdown for easy-to-understand explanations of key financial terms: AAA-rating AAA-rating The best credit rating that can be given to a borrower's debts, indicating that the risk of borrowing defaulting is minuscule.

Why did it take so long to agree the latest tranche of aid?

Despite Greece approving its tough budget for 2013, the next tranche was not released immediately as there was no agreement among Greece's lenders on how to make the country's debt sustainable.

Eurozone finance ministers agreed earlier this month to give Greece two more years - until 2016 - to meet the deficit reduction targets that are a condition of the bailout loans.

The key to releasing the next tranche of bailout loans was to reach agreement on how to make Greek debt sustainable again. Greece's debt is currently forecast to hit almost 190% of GDP next year.

The IMF made clear that it would only consider the debts sustainable if they could be brought down to 120% of GDP by 2020. The IMF will not lend money to a country whose debts it does not deem sustainable.

Under the compromise, Greece's debts are now expected to fall to 124% of GDP by 2020.

This will be done by cutting the interest rate on existing rescue loans, returning profits earned by the European Central Bank on Greek debts it owns, and helping Greece buy back its private-sector debts at their currently depressed market prices.

It will not involve any write-off of the bailout loans owed by Greece - something that Germany and other lenders said would be unacceptable.

The money will not be released until 14 December, in order to allow national parliaments in eurozone countries time to approve the deal.

What happens next?

When Antonis Samaras's New Democracy won the general election in June, he insisted Greece did not need a further bailout but wanted a two-year "breathing space" to meet the tough budget targets attached to the bailout from the EU and IMF.

Greece has now been granted the extra time, but major problems remain and the financial markets are still nervous.

If Greece's economy continues to contract sharply, the country may not be able to cut its overspending as much as planned, and may ultimately be unable to repay its debts, meaning it will need further help. If the rest of Europe is no longer willing to provide it, then Greece may be forced to leave the euro.

There is, of course, the possibility that the Greek people, fed up with rising unemployment and falling living standards, will make it impossible for the government to continue even with the slower rate of austerity that is now planned.

Why does this matter for the rest of Europe?

If Greece does not repay its creditors, a dangerous precedent will have been set. This may make investors increasingly nervous about the likelihood of other highly-indebted nations, such as Italy, or those with weak economies, such as Spain, repaying their debts or even staying inside the euro.

If investors stop buying bonds issued by other governments, then those governments in turn will not be able to repay their creditors - a potentially disastrous vicious circle.

To combat this risk, European leaders have agreed a 700bn-euro firewall to protect the rest of the eurozone from a full-blown Greek default.

Moreover, if banks in the weaker eurozone countries that are already struggling to find enough capital are forced to write off even more loans they have made - something that becomes more likely if the eurozone economy falls deeper into recession - they will become weaker still, undermining confidence in the entire banking system.

Eurozone banks may then find it even hard to borrow, and therefore to lend, potentially sparking a second credit crunch, where bank lending effectively dries up, hurting the economy further.

This problem would be exacerbated by savers and investors taking money out of banks in vulnerable economies, such as Greece, Portugal and Spain, and moving it to banks in safer economies such as Germany or the Netherlands.

These potential scenarios would be made immeasurably worse if Greece were to leave the euro. The country would almost certainly reintroduce the drachma, which would devalue dramatically and quickly, making it even harder for Greece to repay its debts, and setting an even worse precedent.