Director General Sir Andrew Parker has expressed "regret and shame" on behalf of MI5 for the organisation's historical treatment of the LGBT community.
In his final interview before leaving the post at the end of April, Sir Andrew told the BBC that MI5's past approach to homosexuality "must have caused all sorts of hurt".
Being gay was a barrier to employment at MI5 until the 1990s, despite homosexuality being decriminalised in 1967.
Sir Andrew, who joined the organisation in 1983, recalls the policy being "completely outdated". It is the first time a head of MI5 has acknowledged these historical shortcomings. Writing to staff, Sir Andrew added that MI5 had been too passive in not challenging the status quo on vetting as early as the organisation could and should have done.
MI5 is now proud of its record in encouraging a diverse and inclusive workforce. The organisation is consistently ranked in the Top 10 Employers by Stonewall, and was named Employer of the Year at the British LGBT Awards in 2018.
Championing diversity has been a major priority throughout Sir Andrew's seven years as Director General. He stressed: "We want to embrace difference because MI5 positively needs the best talent we can find, from every part of society, because we've all got extremely tough work to do".
Sir Andrew's interview can be accessed here