He was the father of modern computing whose work on the Enigma code at Bletchley Park is said to have shortened the Second World War.

But he was also gay and in those less enlightened times was chemically castrated by an ungrateful nation after being convicted of "gross indecency" with a man in 1952.

Now, nearly 60 years after his suicide from cyanide poisoning at the age of 41, Alan Turing has been officially pardoned by the Queen under the little-known Royal Prerogative of Mercy.

Download the new Independent Premium app Sharing the full story, not just the headlines

The pardon comes after a change of heart by ministers who had previously insisted that Turing was properly convicted of what at the time was a criminal offence.

A pardon is usually granted only when the person is innocent of the offence and where a request has been made by someone with a vested interest, such as a family member. But Turing's pardon has been issued without either requirement being met.

It follows a sustained campaign by scientists, including Stephen Hawking, and a petition to Government signed by more 37,000.

Announcing the change of heart, the Justice Secretary Chris Grayling said Turing deserved to be "remembered and recognised for his fantastic contribution to the war effort" and not for his later criminal conviction.

"His later life was overshadowed by his conviction for homosexual activity, a sentence we would now consider unjust and discriminatory and which has now been repealed," he said. "A pardon from the Queen is a fitting tribute to an exceptional man."

The pardon under the Royal Prerogative of Mercy will come into effect today.

Since 1945, only three high-profile pardons have been granted in England and Wales under the Royal Prerogative: to Timothy Evans, Derek Bentley and Michael Shields.