Labour’s Shadow Justice Secretary Sadiq Khan says the decision to pardon Alan Turing “is a truly fitting tribute” – considering the shameful way he was treated for being gay.

The senior Labour MP said: “This is a long overdue recognition of the crucial role played by Alan Turing in the efforts to win World War II and in our nation’s proud record of scientific discovery. A pardon from the Queen is a truly fitting tribute and reflects the hard work of those who’ve campaigned for many years so that the shameful way he was treated could, in a small but important way, be righted.”

Computer pioneer and codebreaker Alan Turing was given a posthumous royal pardon by the Queen yesterday evening.

It addresses his 1952 conviction for homosexuality for which he was punished by being chemically castrated.

The conviction meant he lost his security clearance and had to stop the code-cracking work that had proved vital to the Allies in World War Two.

The pardon was granted under the Royal Prerogative of Mercy after a request by Justice Secretary Chris Grayling.

“Dr Alan Turing was an exceptional man with a brilliant mind,” said the senior Tory MP.

“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,” said Mr Grayling.

“Turing deserves to be remembered and recognised for his fantastic contribution to the war effort and his legacy to science. A pardon from the Queen is a fitting tribute to an exceptional man.”

The pardon comes into effect on 24 December.

In 2009, after a campaign led by Richard Dawkins, Stephen Fry and Peter Tatchell and supported by PinkNews.co.uk, the then prime minister Gordon Brown issued an apology for Turing’s treatment on behalf of the British Government.

A bill to pardon Turing passed its third reading in the Lords in October. It sought to grant a statutory pardon to Turing. However, it stalled in the House of Commons because of an objection by Tory MP Christopher Chope.

Reacting to the pardon, Prime Minister David Cameron said: “Alan Turing was a remarkable man who played a key role in saving this country in World War Two by cracking the German Enigma code.

“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.”

Labour leader Ed Miliband said: “Alan Turing was a hero and an extraordinary academic – his work helped win World War II. I’m delighted he has received a royal pardon.”

Human rights campaigner Peter Tatchell said: “I pay tribute to the government for ensuring Alan Turing has a royal pardon at last but I do think it’s very wrong that other men convicted of exactly the same offence are not even being given an apology, let alone a royal pardon.

“We’re talking about at least 50,000 other men who were convicted of the same offence, of so-called gross indecency, which is simply a sexual act between men with consent.”

Mr Tatchell said he would like to see Turing’s death fully investigated.

“While I have no evidence that he was murdered, I do think we need to explore the possibility that he may have been killed by the security services. He was regarded as a high security risk,” he said.