Double agent Kim Philby, known as the Third Man, was almost unmasked while living in St Albans, a new book has revealed.

A Spy Among Friends by the noted espionage author Ben Macintyre reveals a little-known crucial episode that occurred when Philby was based in wartime St Albans while running a special counter-intelligence operation for MI6.

The book discloses that only a stroke of luck saved Philby, a member of the Cambridge spy ring who betrayed Anglo-American top secrets to the Soviets during the Cold War, from being exposed as a double agent.

After joining British intelligence in the early days of the war, Philby was appointed to run a special operation to combat German espionage activities in Spain and Portugal. It was based at Glenalmond, then an imposing Edwardian House set in secluded grounds off King Harry Lane in St Albans..

At weekends Philby and his young followers played cricket on the pitch behind Glenalmond before heading to the nearby King Harry pub.

Philby’s deputy at War Station XB was a young Graham Greene, who would later pen classic spy novels such as Our Man in Havana and The Quiet American.

He recalled long Sunday lunches when Philby and his devoted team relaxed during heavy drinking sessions.

Residents of St Albans were unaware of what was going on at Glenalmond – they were led to believe that the occupants were merely young archaeologists working on the ruins of Roman Verulamium.

All the time he was gaining the respect and confidence of his British intelligence chiefs, Philby was secretly gathering top-level secrets and passing them to his Russian spymasters.

Despite – or, perhaps, because of – the remarkable quantity and quality of the material, the distrustful Soviets set him a special test of his reliability telling him to secure the identities of British spies working in the Soviet Union.

It was Philby’s good fortune that the details were housed next door to him in the central registry of MI6 at Prae Wood, St Albans – under the control of the chief registrar, Captain William Woodfield. As the heavy-drinking ex-Special Branch man was a regular at the King Harry, Philby was able to develop a close acquaintanceship as a drinking pal.

Gaining his confidence with ‘copious quantities’ of pink gin and dirty jokes, Philby eventually persuaded Woodfield to hand over the source books containing details of agents in the Soviet Union.

Ironically, these revealed there was no British spy network in Russia at that time because the British were far more focused on the Nazi menace.

When Philby reported back to Moscow they became even more incredulous and suspicious – and his risky endeavours nearly caused his undoing.

To Philby’s great shock, some days afterwards Captain Woodfield requested the source books be returned – despite the fact Philby was convinced he had already sent them back.

After turning his office upside down in a fruitless search, Philby met up with Woodfield again at the King Harry on Friday of that week. Over more pink gins, he was alarmed to hear that MI6 rules meant the head of the service, Sir Stewart Menzies, would have to be informed about the missing records by the following Monday.

Philby knew he was in deep peril if ‘C’, as he was known, discovered he had been delving into material well outside his area of responsibilities.

Ben Macintyre writes that, after a weekend of “simmering panic,” Philby had a last-minute reprieve when Captain Woodfield’s secretary returned to work from a bout of flu and explained to her boss that the ‘missing’ records had been amalgamated with other volumes to save shelf space.

The author concluded: “Had Woodfield’s secretary been slightly more ill, for longer, or had Woodfield been a little less pickled, then Philby’s story would have ended then and there but his luck held.”

Philby went on to betray the Allies on both sides of the Atlantic for many more years.

A Spy Among Friends, by Ben Macintyre, is published by Bloomsbury.

DAVID BROOKS