UK intelligence agency director Robert Hannigan has said it was the "nation's loss" that GCHQ did not employ gay people until the 1990s. A former member of staff called Ian wrote to Hannigan, describing how he was interrogated on suspicion of being homosexual, dismissed and escorted from the building.

"In his letter, Ian asked if I would apologise publicly on behalf of GCHQ – not in some way to 'pardon' him because, as he said, he did nothing wrong – but to apologise to him for his treatment.

"I am happy to do so today and to say how sorry I am that he and so many others were treated in this way, right up until the 1990s when the policy was rightly changed," he said at the Stonewall Workplace Conference.

"The fact that it was common practice for decades reflected the intolerance of the times and the pressures of the Cold War, but it does not make it any less wrong and we should apologise for it.

"Their suffering was our loss and it was the nation's loss too because we cannot know what Ian and others who were dismissed would have gone on to do and achieve. We did not learn our lesson from Turing."

GCHQ\'s Doughnut building in Cheltenham
Rainbow display at GCHQ\'s Doughnut building in Cheltenham. GCHQ

In an interview with PinkNews, Hannigan spoke about the culture and climate of the 1960s. "There were two reasons why there was that policy. Until 1967 it was illegal, and particularly during the Cold War there was the thinking that people could be blackmailed and there was a vetting issue – and there's a dose of societal prejudice thrown in there. We were a victim of the times.

"What have we done to break that down? Obviously, we have changed the policy but I think there's a culture of change to go through."

Hannigan was behind lighting the GCHQ building in a rainbow last year to celebrate International Day Against Homophobia, Transphobia and Biphobia. "It was partly to honour Turing… but it was also an act of atonement – for the lost opportunity of his early death."

Turing faced a conviction in 1952 for gross indecency, after which he was chemically castrated. His criminal record caused the loss of his security clearance and ended his pioneering work on artificial intelligence and cracking codes. He committed suicide in 1954 by eating an apple injected with cyanide. Turing received a posthumous royal pardon in 2013.