The author is a Reuters Breakingviews guest columnist. The opinions expressed are his own.

Central bankers sometimes distinguish between peacetime, when economies are running relatively normally, and war, when there is a financial crisis. Mario Draghi is having a good war.

The European Central Bank president has done almost everything he can to keep Greece in the euro without breaking his organisation’s rules. Although Draghi has been attacked by Athens for asphyxiating the country and by hardliners for being lax, he has got the balance about right.

Greece’s radical left government has complained that the ECB cut off funding to the country’s banks in order to bring it to heel and accept more austerity. Some wilder voices have even argued that the ECB deliberately provoked a depositor run so that it would have an excuse to close the banks.

In fact, Draghi has been holding off hardliners on the ECB’s Governing Council who wanted to cut off liquidity to the banks completely. As he said on July 16: “There were some who were actually calling for a cut to zero, which would have caused an immediate collapse of the banking system.”

It has been easy for critics to misrepresent or fail to understand the ECB’s actions because of the complexity of central banking operations.

One misapprehension is that the ECB’s job is to act as a lender of last resort to banks in all circumstances. No central bank operates in that way because, otherwise, banks would have no incentive to behave responsibly and taxpayers would be endlessly bailing them out.

Instead, the ECB reasonably insists on banks being solvent and being able to post adequate collateral in return for liquidity. In recent months, because the Greek banks’ finances are entangled with those of their government, there have been doubts about both their solvency and the collateral they have been providing.

As fears rose that Athens would go bust, so did the risk that the financial system would become bankrupt. The ECB adjusted its lending policies as the prospects of Greece reaching an agreement with its creditors, without which it would become insolvent, increased or fell.

The central bank’s first move, on Feb. 4 soon after Alexis Tsipras was elected prime minister, was to rule that banks could no longer use Greek government bonds as collateral to receive liquidity from the ECB itself. Instead, the banks had to get emergency liquidity from the Bank of Greece, the country’s own central bank.

Given that Greece has been close to bankruptcy for the last five years, one might ask what the ECB was doing accepting the country’s bonds as collateral even before Feb. 4. The answer is that it had given the country a waiver from its normal rules, which require bonds to have a high credit rating. It had justified this waiver, which had also been provided for other crisis-ridden countries, on the grounds that Greece was in a bailout programme and was implementing that properly.

Having a waiver in these circumstances is reasonable. But equally, by early February after Tsipras made clear he wanted to tear up the old bailout, it wasn’t unreasonable for the ECB to conclude that the conditions were not met – although it should probably have waited a little longer.

This, however, did not mean that Greek banks were cut off from liquidity. In the subsequent months, the Bank of Greece provided them with tens of billions of euros of emergency liquidity. The ECB Governing Council authorised this, despite misgivings from some of its members, most prominently Jens Weidmann, who runs Germany’s central bank, the Bundesbank.

The next move came on June 28, the day after Tsipras called a referendum on whether to accept the creditors’ terms for a new bailout. When the Greek prime minister said he would campaign to reject the terms, the euro zone finance ministers decided not to extend the old bailout, which was about to expire on June 30.

One can debate whether the finance ministers were right to bring talks on the old bailout to an end. But once they had done so, the ECB had little choice but to restrict the emergency liquidity that the Bank of Greece was supplying. The prospect of Athens defaulting on its creditors had risen sharply.

The ECB, though, did have an important decision to make: either freeze liquidity at the level it had reached, or cut it. Doing the latter would have caused a collapse of the banking system and probably driven Greece out of the euro. Draghi and his allies on the Governing Council fought against that option and prevailed. Even freezing liquidity, though, meant the Greek banks had to close and cash withdrawals had to be limited to 60 euros per day.

Now that Tsipras is back in talks with his creditors about a new bailout, the ECB has started to unwind some of its actions. On July 16, it authorised another 900 million euros of emergency liquidity. That was enough for the banks to reopen on July 20.

But before capital controls can be fully lifted, further steps – including the restoration of the waiver and the recapitalisation of the banks – will be needed. During this process, Draghi will need to continue striking a balance between the hawks arguing for a hard line and the doves pushing for leniency. Europe should hope he keeps getting it right.