A ban on LGBT staff at GCHQ until the 1990s, and the mistreatment of employees who were discovered to be gay, was wrong, the spy agency's boss Robert Hannigan has said.
Speaking at the Stonewall Workplace Conference on Friday, Hannigan made particular reference to mathematics and computer genius Alan Turing, who conducted monumental code-breaking during the second world war.
Turing was convicted and subjected to chemical castration as a result of his sexuality. He ultimately took his own life in 1954.
Noting the spy agency "did not learn our lesson from Turing", Hannigan said that the suffering of other gay employees and would-be employees 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".
"Ian" was another employee who was removed from GCHQ in the 60s as a result of his sexuality, and who asked for an apology 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," Hannigan said.
He added that while the intolerance shown reflected the era in which Turing and "Ian" were mistreated, "it does not make it any less wrong and we should apologise for it."
Hannigan said he looked forward to a future of much greater diversity at GCHQ so to learn from the past, and be able to embrace the talent of people of every orientation and background.
"And that is the real point of diversity for me. To do our job, which is solving some of the hardest technology problems the world faces for security reasons, we need all talents and we need people who dare to think differently and be different," he said.
"We need different backgrounds, experiences, intellects, sexualities, because it is in mixing all of those together that you get the creativity and innovation we desperately need.
"Dull uniformity would completely destroy us."