Alistair Darling's phone rang. It was 7 October 2008 and the chancellor of the exchequer was in Luxembourg, struggling to concentrate on the finer points of insurance regulation. The caller was Sir Tom McKillop, chairman of Royal Bank of Scotland, and his message was brief: "We are haemorrhaging cash. What are you going to do about it?"

The chancellor knew that Britain's biggest bank was in trouble even before McKillop came on the line, yet even the normally phlegmatic Darling was surprised at the size and immediacy of the crisis. "I asked how long he could last, expecting him to say that we had 24 hours," Darling recalled in an interview with the Guardian to mark the fifth anniversary this weekend of the bankruptcy of Lehman Brothers – the event that provoked the global financial crash and, along with other seismic shocks, pushed RBS to the brink.

Instead, McKillop said RBS's cash would last for only two or three hours. Unless there was immediate help, the bank would have to cease trading by the end of the day.

Darling could see the irony of the situation. "Here was the chairman of one of the world's biggest banks, who had shown disdain for politicians, asking us what we were going to do about it." Stifling any urge to delight in McKillop's predicament, the chancellor said the government would shortly announce details of a rescue plan for UK banks caught up in the backwash from the collapse of Lehman, little more than three weeks earlier.

For Darling, this was the stuff of nightmares. It wasn't simply that cash machines would stop working and cheques would no longer be cashed, although that was perceived by the Treasury and the Bank of England as a clear risk. It was the knowledge that the meltdown of a bank the size of RBS would send shockwaves through an already weakened global financial sector and bring other institutions down with it.

"It sent a shiver down my spine. I knew from what had happened to Northern Rock a year earlier what could happen. And this was a massive bank. It would have been a catastrophe had RBS collapsed," he said. "I am often asked which of my 1,000 days as chancellor was the worst. I am very spoiled for choice, but that was it. We were on the brink of a complete collapse of the world's financial system. RBS would have taken the rest of them down."

What could have gone down in history as Black Tuesday dawned with the chancellor flying out for talks with fellow finance ministers. Darling would rather have been at his desk in the Treasury, but decided that a no-show could spook the markets. With panic in full spate, it was imperative for him to be seen keeping calm and carrying on.

A news report that RBS would be bailed out by the Treasury had led to a wave of selling in the City. In a frenetic morning's trading, the bank's shares had been suspended, re-listed and then suspended again before McKillop called.

Tuesday 7 October marked the climax of Britain's silent bank run. Although it was less visible than the queueing outside branches of Northern Rock a year earlier, the prolonged unwillingness of banks to lend to each other threatened to be far more damaging.

Lord Myners, brought in by Gordon Brown as City minister after the Lehman collapse, said he was shocked when shown official figures showing how inter-bank lending had dried up.

"This was the real bank run," Myners said. "You think of the senior citizens outside Northern Rock branches, but the real run was the one that took place in October, when really substantial depositors were willing to pay penalties to move their deposits. Deposits were not being renewed.

"There was a waterfall chart. You could see the proportion of deposits that was not being renewed – hence the need to do something – which had an element of shock and awe about it."

For those running Britain's banks, the change in the climate was sudden and, for their institutions, potentially fatal. In the good years, banks had become highly leveraged – they had increased their lending far more rapidly than they had built up capital to guard against losses. With markets booming, the banks' supposedly failsafe models showed that catastrophic losses were out of the question. In any event, they could always rely on the wholesale money markets – populated by other financial institutions – to see them through any cash-flow problems.

These beliefs were shattered in the weeks that followed the Lehman collapse. None of the executives at RBS or HBOS, the two most prominent casualties of the crisis, would talk to the Guardian for this series but it was clear from the testimony of Andy Hornby, HBOS's chief executive, and Lord Stevenson, its chairman, to parliamentary committees that they were completely flummoxed – and terrified – when they found that the wholesale markets were closed for business.

Lord Turner, who took over as chairman of the Financial Services Authority a week after the American authorities failed to find a buyer for Lehman, believes the crisis pre-dated the collapse of Lehman, and even the run on Northern Rock in September 2007. "For me the lesson learnt is that the roots of this crisis go back very deep. Over a number of decades we allowed too much leverage to grow in the real economy, and we allowed the banking system to become over-leveraged. I think we were running a system with such small buffers of capital and liquidity that by 2006-07 a crisis was bound to occur.

"You can go back and ask, had something been done differently in 2007 might the precise path of the crisis been different: but that's not the key point. We had created a system by 2006 with such a buildup of debt that it was inherently unstable, and that was going to produce a massive crisis.

"We created an over-leveraged financial system and an over-leveraged real economy. We created a system such that even if the direct cost of bank rescue was zero, the impact of their near-failure on the economy was vast."

The perils of over-leveraging had become apparent long before the US authorities gave up the fight to save Lehman on 15 September 2008, and condemned it to bankruptcy. Banks were using each other to fund their businesses rather than depositors. So even before Lehman collapsed, bankers could see the temperature was rising.

Douglas Flint, now chairman of HSBC, Britain's largest bank, but its finance director during the crisis, said: "It was very clear that many investment banks were dependent on being able to roll over short-term liquidity, and we could see the parcel of unencumbered assets being used as collateral was getting smaller."

Problems first surfaced in the American sub-prime mortgage market, where too many home loans had been extended to borrowers with no chance of ever repaying them. There was even a nickname for them – "ninja" loans, for people with no income and no job or assets. Those risky loans were bundled up with less risky ones and sold off in parcels to banks around the world. The belief was that these collateralised securities offered high returns at minimal risk. The belief was that not all mortgage borrowers would default at the same time. That belief was wrong.

It was also universal, which was why the crisis proved to be so debilitating. Banks were big, global, had utter faith in the supposed perfection of unfettered markets, and were all operating the same mathematical models of risk. Speaking in 2011, Paul Volcker, the former chairman of the US Federal Reserve, put the crisis down to an "unjustified faith in rational expectations, market efficiencies and the techniques of modern finance".

By September 2008, the system was ready to blow. The period of calm following the nationalisation of Northern Rock in February 2008 and the rescue of the American investment bank Bear Stearns in March the same year proved to be a phoney peace.

In its May 2008 financial stability review, the Bank of England was wildly optimistic about the future. It said: "The most likely path ahead is that confidence and risk appetite return gradually as market participants recognise that some assets look cheap on a fundamental basis. But with sentiment still weak and deleveraging continuing, downside risks remain."

These risks grew more prominent as the summer wore on. Darling was alerted to the worsening state of the British economy by falling tax revenues coming in to the Treasury. In the US, the Bush administration had to take the two institutions that guaranteed US mortgages – Freddie Mac and Fannie Mae – into federal protection.

Lehman was the next domino to fall. Its fate was sealed when Darling refused to provide state guarantees for a takeover by Barclays that Bob Diamond, then the head of Barclays' investment bank, had been trying to broker on the weekend of 13-14 September. "I could not imagine standing up in the House of Commons on the Monday morning explaining that we had put the UK taxpayer in hock so that Barclays could buy Lehman. Half the Barclays board was relieved," Darling said.

Andrew Bailey, then chief cashier at the Bank of England and now its deputy governor and head of the new Prudential Regulation Authority, recalled: "It was a strange weekend. We had almost no control over it because the events were happening in New York."

Lehman was the trigger for the most dangerous phase of the crisis. "Lehman in a violent way brought on HBOS's funding problems because of its over-dependency on wholesale funding," said Bailey. In the weeks that followed, the British government nationalised buy-to-let specialists Bradford & Bingley, while the Irish authorities prompted fury among their European Union partners by offering a blanket guarantee to depositors. Iceland simply allowed its three biggest banks to collapse.

Just two days after Lehman collapsed, the Americans bailed out the giant insurer AIG, which had guaranteed the banks' multibillion-dollar exposure to sub-prime loans. Without a bailout, many more banks would have followed Lehman into bankruptcy. The US administration also turned Goldman Sachs and Morgan Stanley into traditional commercial banks so that they could get federal financial support, and proposed that hard-pressed firms could put their toxic loans into a Troubled Asset Relief Programme (Tarp). When Congress initially refused to sanction Tarp, the Dow Jones Industrial Average fell by more than 700 points in a day.

In London, earlier tensions between the Treasury and the Bank of England about how to handle the crisis had been smoothed over. Darling had been irked at what he saw as the over-academic approach of the governor, Mervyn King; at one point Darling even discussed the "nuclear option" of over-ruling Threadneedle Street in order to provide more support for the City.

By late September and early October, it was clear to the Bank, the Treasury and the FSA alike that emergency action was needed. In his first week at the FSA, Turner had dinner at the Bank with King. Over a bottle of red wine from the cellars, King explained that British banks were facing a full-scale solvency crisis.

Turner describes what was happening in the markets as a snowball effect. "Three-month deposits were running off but lenders didn't want to give another three months – they'd give just overnight. So by the next day you had a bigger problem, because there were more term deposits maturing plus the overnight deposits from the night before – like a giant snowball rolling forward, getting bigger day by day."

The scene was set for a series of eyeball-to-eyeball meetings at the Treasury in early October. On one side of the table sat the heads of RBS, Lloyds, HSBC, Standard Chartered, Santander, HBOS, Barclays and the Nationwide building society. On the other side sat Darling, King and Turner, flanked by their advisers. Myners says he was shocked at the bankers' lack of humility and the way they tried to intimidate ministers even when the crisis was at its most acute.

That hubris was not to last for long: former RBS boss Fred Goodwin later described the events that led to his departure and the bailout of RBS as akin to "a drive-by shooting". He was out of a job – axed by chairman McKillop and senior independent director Bob Scott. Myners says he also wanted McKillop's resignation but was warned by Scott that the entire board would quit. A compromise was reached whereby McKillop would go at the spring AGM, although he eventually went earlier. The cull also included Stevenson and Hornby, who had their tenures cut short at HBOS.

By the evening of Monday 6 October, Darling, King and Turner duly told the bankers that it was time for "shock and awe". Details of the secret meeting leaked within hours, with reports that RBS was first in line for government cash.

But it wasn't just RBS in trouble: the capital position of most of Britain's banks had to be strengthened. Those that could raise money themselves were told to do so; Barclays, controversially, turned to Middle Eastern investors. Those banks that couldn't find external backers – RBS and the enlarged Lloyds, now linked to an ailing HBOS – found themselves part-owned by the taxpayer. For many socialists this was a moment they thought would never come: a Labour government in control of the commanding heights of the economy.

The final part of the plan involved other countries copying Britain's blueprint. Joint action was discussed at the annual meeting of the International Monetary Fund the weekend after the Darling-McKillop phone call, and action in the US and Europe swiftly followed.

Even then, it was a close-run thing. The period between mid-September and early October 2008 has already gone down in history. The impact of Lehman's collapse was swift, profound, global and long-lasting. Half a decade on, the ramifications are still being felt: RBS and Lloyds are still partly nationalised, with plans only recently announced by George Osborne for part of Lloyds to be sold off. The credit crunch that starved businesses of finance has still not ended. Countries that saw their public finances wrecked by the crisis – Britain among them – are still trying to pay off their debts.

In a lost decade for living standards, it is likely to be 2018 before disposable incomes return to pre-crash 2008 levels: only the second time in British peacetime history that individuals will be less prosperous at the end of a 10-year period than they were at the start.

But it could have been worse. Policymakers such as King consider the near-meltdown of 2008 to have been more profound than the 1929 Wall Street Crash that which led to the slump of the 1930s. But, so far at least, there has been no repeat of the Great Depression.