SELDOM has such scepticism surrounded a merger as when, in the depths of the 2008 financial crisis, Lloyds TSB decided to buy its ailing competitor, HBOS, to create the biggest domestic bank in Britain. Officials worried about financial stability were desperate for a buyer, yet competition regulators were aghast at the creation of a behemoth with 30% of the market for personal accounts. Shareholders, for their part, pummelled Lloyds stock, worried that it was paying too much for a bust bank. Even Alistair Darling, then chancellor, had doubts, writing later in his memoirs how it “was not obvious” that this was “an opportunity” for Lloyds. Mr Darling said he told the then chief executive to be sure the bank “knew what it was taking on”.

In the short term, the sceptics were proved right. Within months the renamed Lloyds Banking Group (LBG) had collapsed into the arms of the state, needing a £20 billion ($35.3 billion) bail-out in exchange for a 43% stake. Yet its troubles only got worse. It has posted losses in each of the past three years, running up a combined deficit of £4.3 billion over that period. Its share price had also languished well below the level at which the government would break even on its investment, delaying a sale of its shares—which today are worth some £700 to each British taxpayer.

The bank’s turnaround has, however, been as sudden as it was unexpected. After losing £1.4 billion last year, it is now expected to generate profits of about £2.6 billion this year. Its shares have surged, moving above their book value for the first time in two years (see chart). They are now at levels last seen before the financial crisis. Moreover, its recovery is thought likely to pick up speed. Analysts reckon Lloyds may earn £3.7 billion next year and as much as £4.6 billion the following one. These numbers ought to come with a health warning—analysts have about as much success predicting company results as roulette players have of beating the house—yet there are clear reasons for optimism. The most important is that António Horta-Osório, who took over as chief executive in early 2011, has been quietly refitting the bank’s inner workings. His little-noticed re-engineering of the bank might seem more suited to a carmaker than a financial institution: it is largely about reducing the cost of “manufacturing” (ie, selling and processing) the bank’s various financial products. Usually a bank boss is obsessed with the cost of raw materials, its deposit and debt borrowings. Over the past two years the bank has cut almost in half the number of suppliers it deals with (to a mere 9,567). It has trimmed the number of legal entities in its sprawling structure by more than a third, to a still astonishing 1,035. Layers of management have gone, too. Computer systems and processes to automate transactions—transferring cash between accounts, for example—have been improved. The changes may seem small beer, yet they quickly add up. Annual operating costs are likely to fall to £9.2 billion next year from more than £11 billion two years ago. Outside the engine room, Lloyds has also improved its net-interest margin, a measure of the difference between what it pays to borrow and what it receives when it lends. It has done so largely by reducing a bloated balance-sheet and cutting its reliance on flighty wholesale funding. This should provide further fuel for earnings growth in a few years, when Britain’s economy recovers and interest rates start to rise: higher interest rates drive up returns on loans and mortgages without an equivalent increase in the rates depositors are paid. (There are risks here, too. Its massive market share may well come back into the spotlight if its margins are too juicy.)

With earnings rising and a pledge by Mr Horta-Osório to start paying dividends again within a few years, the government looks set to turn a tidy profit on its stake in the bank. Its first sale of shares is likely soon, making a stark contrast to its holding in Royal Bank of Scotland (RBS).

RBS, which was also nationalised at the height of the financial crisis, seems as far as ever from being privatised. The bank named Ross McEwan as its new chief executive on August 2nd. His brief is daunting. Whereas Lloyds is a relatively simple retail bank with a domestic focus, RBS is an almost unmanageable hodgepodge of retail and investment banking businesses (see chart). It reported a massive £6 billion loss in 2012.

Nor is the Royal Bank ready to ape the turnaround at Lloyds. Before setting out on a manufacturing revolution in RBS’s retail-banking arm, a business that has suffered from shameful glitches in its creaky computer systems, Mr McEwan will have to make tough decisions on its investment bank. That business is haemorrhaging staff and lacks the scale to compete with bigger global investment banks such as JPMorgan Chase and Goldman Sachs. Britain’s government had little choice but to save RBS almost five years ago. If it wants to turn the taxpayer stake into a profitable privatisation, as looks likely with Lloyds, it may have years longer to wait.