WHEN the euro zone rescued Greece in 2010 Germany insisted on enlisting the IMF. Some worried about letting the Washington-based institution meddle in Europe. But Germany wanted the IMF as external enforcer, to impose rigour not only on Greece but also on the soft-hearted European Commission.

More than two years later, the enforcer has at times been Greece’s main helper. It has sought to ease the pace of austerity. And it has been at odds with Germany over the hitherto unthinkable: the need to write off some of the billions that Greece still owes. In a string of late-night meetings in Brussels, Christine Lagarde, the IMF’s boss, has injected some common sense into the latest rescue of Greece, finalised this week. Greece has been given more time to reach its budget targets, and the terms of euro-zone loans have been softened. For all the doubts about whether the latest numbers add up, something important has happened: the euro zone has come to accept that Greece cannot bear the burden of its debt, and that creditors will have to take losses.

This is not how it was meant to be. Bringing in the experience of the IMF was intended to safeguard German taxpayers’ billions. Angela Merkel, the German chancellor, claimed other vulnerable countries would be dissuaded from asking for bail-outs because they would see that “the path taken by Greece with the IMF is not an easy one”. Instead the crisis worsened (Cyprus is about to become the fourth country to receive a bail-out) and the European Central Bank has had to step in. On November 28th the European Commission proposed a step-by-step blueprint to fix the underlying flaws of the euro. It includes an embryonic euro-zone budget in the next 18 months and a pooling of euro-zone debt in the next five years. In the long term, it wants a “deep and genuine” economic and monetary union, with a euro-zone budget financed by its own taxes and full-fledged joint Eurobonds.

All this will take time, and difficult treaty changes. Yet the original and unending crisis in Greece is undermining the euro now. Much of the blame must lie with Greece’s politicians. But the euro zone has also made mistakes, including a failure to recognise that Greece was bust. This meant Greece was pushed into sharp, depression-inducing austerity (Germany initially insisted on charging punitive interest rates). And euro-zone leaders fell into a costly muddle about Greece’s huge debt. When “haircuts” were imposed on private bondholders the euro zone got the worst of both worlds. Much of the benefit was lost because a good part of the debt had been offloaded onto official lenders; and contagion spread across the periphery. Europe’s creditors must now confront the question: how much of Greece’s official debt needs to be written off?

The IMF has at times been part of this confusion, especially under Dominique Strauss-Kahn (before he was brought down by a sex scandal), who was persuaded to play along with the fiction that Greece was solvent. Under Ms Lagarde it has become more clear-eyed. Though hardly popular in Greece, the IMF has become increasingly outspoken about the damage from excessive austerity. It pushed for Greece to get two more years to reach a big primary budget surplus (before interest payments).

The IMF’s toughest struggle has been to convince Germany and others that Greece cannot repay the money it owes. Reckoning debt sustainability is an inexact science. The threshold set for Greece last year, of debt falling to 120% of GDP by 2020, was defined by politics. The IMF thinks that it is still too high. In any case Greek debt is now forecast to be at 144% of GDP by 2020.

Explore our interactive guide to Europe's troubled economies

Ms Lagarde made plain that, unless Greece’s debt was cut back, the IMF would lend no more money. Germany retorted that any haircut would be illegal. Some money could be found from the profits that the ECB has made by buying Greek bonds, said euro-zone ministers. Perhaps the deadline could be pushed back to 2022, or the Greeks could be made to run an even bigger surplus. Perhaps Greece could use bail-out money to buy back bonds at distressed prices. What about a promise to deal with the debt in future? Yet Ms Lagarde stuck to her position, and demanded action upfront.

The compromise was a commitment to cut Greece’s debt to 124% of GDP in 2020 and to “substantially below” 110% of GDP two years later. Greece’s interest rate was cut by one percentage point, maturities were doubled to 30 years, and interest payments were deferred by ten years. And there was a promise to do more if necessary, once Greece reaches a primary surplus.

Crossing the line

This is still not the clear write-off the IMF wanted. But, in disguised form, it amounts to something similar: creditors have acknowledged that they must take losses to keep Greece in. “The Rubicon has been crossed. Greece will not be thrown out of the euro and it can celebrate,” says one veteran. Restoring confidence in Greece’s future is vital to its recovery. Ministers in Athens talk of having a chance, for once, to exceed expectations.

Caution is in order. The Greek economy is still shrinking, and Greece faces years of unpopular public-spending cuts. Structural reforms have been slow; privatisation almost non-existent. Greek politics remains fragile. Germany understandably wants to keep the pressure up. It does not want to do too much before its own election next autumn, and will be reluctant to write off debt even afterwards. But Italy and Spain are among those now lending money to Greece more cheaply than they can borrow. Germany, too, will also have to take some pain.

As they prepare to debate the future of the euro zone at their next summit on December 13th and 14th, leaders should draw one lesson from the sad mess in Greece. Delaying the inevitable only makes it more painful and more costly.