Alan Turing, the extraordinarily gifted British mathematician, logician, computer scientist and code-breaker, received a pardon from Queen Elizabeth II on Monday for his conviction on charges of homosexuality, which was considered a crime in the UK until 1967.

Turing, one of the pioneers of computer science, is credited with helping the Allies win World War II by cracking the secret codes used by German submarines. However, Turing faced criminal prosecution because of his sexual orientation in 1952, leading him to take his own life two years later. The pardon, on Monday, was announced by Chris Grayling, the British justice secretary who had made the request to the queen, the New York Times reported.

“His action saved countless lives. He also left a remarkable national legacy through his substantial scientific achievements, often being referred to as the ‘father of modern computing,’” Prime Minister David Cameron said in a statement.

Born in 1912 in London, Turing worked for the Government Code and Cypher School, Britain's code-breaking center during World War II. He was made an officer of the Order of the British Empire, because of his efforts in breaking German ciphers during the war.

Grayling said, in a statement, that Turing’s most remarkable achievement was helping develop the machines and algorithms that helped decode the complex Enigma code used by Germany in World War II.

After the war, Turing joined the National Physical Laboratory, or NPL, where he developed one of the first designs for a computer that could store program instructions in electronic memory. After leaving the NPL, he joined the Computing Machine Laboratory and designed the Ferranti Mark I, which is considered to be the first electronic digital computer to be commercially available.

During this time, Turing continued to do more abstract work in mathematics and, in 1950, he proposed an experiment in artificial intelligence, which became known as the Turing Test, a measure to test whether a machine can think.

When Turing’s homosexuality resulted in a criminal prosecution, he was forcibly treated with female hormones, a process known as chemical castration, as an alternative to prison. The conviction also led to him losing his security clearance.

In 2009, then British Prime Minister Gordon Brown issued a formal apology to Turing on behalf of the government, observing that the mathematician had been treated “terribly” for his conviction of “gross indecency” for being homosexual.

After Cameron’s government denied Turing a pardon in 2012, an online petition appeared urging a pardon for him. Here is an excerpt from the petition, which received more than 37,000 signatures:

We ask the HM Government to grant a pardon to Alan Turing for the conviction of 'gross indecency.’ In 1952, he was convicted of 'gross indecency' with another man and was forced to undergo so-called 'organo-therapy' - chemical castration… Two years later, he killed himself with cyanide, aged just 41. Alan Turing was driven to a terrible despair and early death by the nation he'd done so much to save… This remains a shame on the UK government and UK history. A pardon can go to some way to healing this damage.

Here is a video documentary from the London Science Museum about Turing’s life and legacy: