Britain has granted a posthumous pardon to Alan Turing, the World War II code-breaking hero who killed himself after he was convicted of the then crime of homosexuality.

Turing is often hailed as a father of modern computing and he played a pivotal role in breaking Germany's Enigma code, an effort that some historians say brought an early end to World War II.

Alan Turing died in 1954 after eating an apple laced with cyanide, two years after he was sentenced to chemical castration.

He died in 1954 after eating an apple laced with cyanide, two years after he was sentenced to chemical castration for the "gross indecency" of homosexuality. A coroner ruled that Turing killed himself, though this has since been questioned.

The Queen has now pardoned Turing for "a sentence we would now consider unjust and discriminatory", Justice Minister Chris Grayling said.