Alan Turing took his own life in 1954, just before his 42nd birthday

Alan Turing, the mathematician who helped to crack the Enigma code but who took his own life after a conviction for “homosexual activity”, has been given a posthumous pardon.

The official Government announcement marks the successful end of a campaign to restore the honour of a brilliant scientist and war hero.

Dr Turing’s code-breaking work at Bletchley Park during the Second World War saved thousands of lives and helped to lay the foundations for modern computing.

Six years later he was made a Fellow of the Royal Society in recognition of the work that he had carried out in his twenties.

However, in 1952 the logician — whose Turing machine used new concepts such as the algorithm to foreshadow the modern computer — was convicted