The last British hung parliament began with an election shock. During the February 1974 campaign, Edward Heath's Conservatives led in almost every poll. The Labour leader, Harold Wilson, campaigned wearily and was rumoured to be seriously unwell. But on polling day, the Liberal vote surged, damaging the Tories more than Labour, and the Conservative government watched its majority ebb away. The final result was Labour 301 seats, the Tories 297 and the Liberals 14.

The Conservatives had still narrowly won the most votes, and Heath, a stubborn prime minister battered by strikes, a sudden recession and Tory rebellions, was determined to cling on. There had not been a hung parliament for decades, and in 1974, as now, there were no precise rules about how to resolve the situation – only the convention that the party leader who was best placed to win the support of the Commons would be asked by the monarch to form a government.

For four days after the election, Heath sought to claim that position. He stayed in Downing Street and tried to contact the Liberal leader, Jeremy Thorpe. But Thorpe, a man of theatrical political gestures, was still in his Devon constituency leading a torchlit victory procession, and for an entire evening could not be reached. When he did return to his Devon home and was told that Downing Street had called, an undetected fault at the local telephone exchange – in 1974 a lot of Britain's infrastructure was creaky – meant many more hours of fruitless calls from Downing Street while Thorpe sat baffled beside a silent phone. After midnight, Heath finally invited Thorpe to London for secret talks.

The following morning, Thorpe pretended to journalists surrounding his house that he was going for a walk, crossed muddy fields to a nearby farm, picked up his briefcase and a car, and slipped on to a train to London. But news of the talks got out. The two leaders met at No 10 with television cameras and leftwing protesters jostling outside, amid widespread fears that the pound and Britain's strained public finances would be targeted by the markets if a stable and fiscally austere government was not quickly formed. Wilson, meanwhile, went to his country residence, played football with his dog for the photographers, and waited: cannier than Heath, he sensed the fragility of the Tories' position.

Heath asked Thorpe if the Liberals would join him in a coalition, in return for a cabinet seat for Thorpe and, among other concessions, an official inquiry and free vote in the Commons on electoral reform. Accounts vary as to how Thorpe responded. Thorpe says in his memoirs that he told Heath the Liberals had "grave reservations" about serving under a defeated prime minister and were "hostile" to a coalition. But a recently declassified account by Robert Armstrong, Heath's principal private secretary, the only other person present at the talks, portrays Thorpe as keener: "Mr Thorpe concluded by thanking the prime minister for giving him so much time. He would discuss what had [been] said with his colleagues, and be in touch again as soon as possible." Heath said in his autobiography that there was another sticking point: that Thorpe wanted to be home secretary, and "I had been warned by the secretary of the cabinet that there were matters in Thorpe's private life, as yet undisclosed to the public, which might make this a highly unsuitable position for him to hold."

Thorpe consulted his colleagues, he and Heath met again, but gradually the prospect of a deal faded. The Liberals wanted more – such as a guarantee of electoral reform – than Heath could offer, and neither party, having just competed for the same voters, sufficiently trusted the other. As a final throw, Thorpe suggested "a national government" also involving Labour, but Heath and his cabinet considered it politically impractical. On his last afternoon in Downing Street, "The prime minister lunched alone," Armstrong records. "He confessed to me that he felt worn out." That evening, Wilson became prime minister and formed a minority government without the Liberals.

It lasted seven months. Tory-supporting newspapers forecast an economic collapse and a takeover by the far left or the far right. Retired soldiers formed ominous-sounding paramilitary networks. But the meltdown never quite came; instead, there was a quieter calamity: the economy continued to weaken, public spending continued to grow unsustainably, and the ageing Wilson did too little to stop either. In October 1974 he called another election and won a frail majority of three. It would take almost another decade, until Margaret Thatcher's 1983 election landslide, for political stability to return.

When the Lights Went Out: What Really Happened to Britain in the Seventies, by Andy Beckett, is published by Faber & Faber, £9.99.