Alan Turing revealed he was gay to the authorities by falling for an "old police trick," New Statesman legal writer David Allen Green reports.
Reporting a theft to police in 1952, Turing was forced to fabricate details of the account to conceal his relationship with a man.
Asked to repeat the account a week later by police, Turing was unable to accurately remember some of those fabricated details, Allen Green writes.
On realising his lies had been exposed, the brilliant mathematician produced a five-page letter admitting untruths as well as describing graphic details of his homosexual relationship.
The statement was enough for police to convict Turing and arrest his partner.
Second World War codebreaker Alan Turing, has been given a posthumous royal pardon for a 61-year-old conviction for homosexual activity - still an offence in the UK in the 1950s.
The Cambridge mathematician has been hailed a national hero for his work to help break the German Enigma Code at Bletchley, near Milton Keynes during the war.
News of the royal pardon granted posthumously to Alan Turing has been applauded as a "just reward" for the code-breaker.
Iain Stewart, Conservative MP for Milton Keynes South, who was involved in the campaign to secure a royal pardon, said: "Alan Turing was an incredibly important figure in our history. He was the father of computer science and the originator of the dominant technology of the late 20th century."
Gay rights campaigner Peter Tatchell said that the granting of the royal pardon was "long overdue" and called for the same treatment to be given to others convicted in similar circumstances.
He said: "Singling out Turing just because he is famous is wrong. Unlike Alan, many thousands of ordinary gay and bisexual men who were convicted under the same law have never been offered a pardon and will never get one.
"An apology and pardon is due to another 50,000-plus men who were also convicted of consenting, victimless homosexual relationships during the 20th century."
Ed Miliband has spoken of his "delight" that Alan Turing has received a Royal Pardon.
Reacting to the news on Twitter, the Labour leader posted:
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.
Dr Alan Turing died of cyanide poisoning and an inquest recorded a verdict of suicide, although his mother and others maintained his death was accidental.
There has been a long campaign to clear the mathematician's name, including a well-supported e- petition and private member's bill, along with support from leading scientists such as Sir Stephen Hawking.
The pardon under the Royal Prerogative of Mercy will come into effect today.
The Justice Secretary has the power to ask the Queen to grant a pardon under the Royal Prerogative of Mercy, for civilians convicted in England and Wales.
A pardon is only normally granted 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 on this occasion a pardon has been issued without either requirement being met.
David Cameron has paid tribute to Alan Turing for his role in "saving Britain in World War Two" after the famous code-breaker was awarded a a posthumous royal pardon.
The Prime Minister 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."
The Bletchley Park computer pioneer Alan Turning has been given a posthumous pardon more than 50 years after being prosecuted for homosexuality.
Turing is widely considered the father of computer science. He went to Cambridge University and during the Second World War he was based at Britain's codebreaking headquarters near Milton Keynes.
He was convicted of in 1952 when homosexuality was illegal in the UK; he committed suicide two years later.
Second World Warcode-breaker Alan Turing has been given a posthumous royal pardon for a 61-year-old conviction for homosexual activity.
Dr Turing, who was pivotal in breaking the Enigma code, arguably shortening the Second World War by at least two years, was chemically castrated following his conviction in 1952.
His conviction for "gross indecency" led to the removal of his security clearance and meant he was no longer able to work for Government Communications Headquarters (GCHQ) where he had continued to work following service at Bletchley Park during the war.
Dr Turing, who died aged 41 in 1954 and is often described as the father of modern computing, has been granted a pardon under the Royal Prerogative of Mercy by the Queen following a request from Justice Secretary Chris Grayling.
"Dr Alan Turing was an exceptional man with a brilliant mind," Mr Grayling said.
Bletchley Park, the home of the second world war codebreakers, is to unveil the latest stage in its restoration project.
Hut 11 has been restored thanks to a legacy left by a Bletchley Park veteran and will be officially opened later this morning.
The wartime Turing-Bombe hut was nicknamed the Hell Hole by the Women’s Royal Naval Service (WRNS) who operated the Bombe machines because it was so hot and noisy.
The new exhibition includes quotes from the women, telling the story of their time at Bletchley Park.
The historic site of Bletchley Park near Milton Keynes has been brought into the 21st century with a multi-media guide.
The interactive handheld device is available to visitors and will help them explore the home of the Second World War Codebreakers.
It includes an adult tour and one specifically designed for children with puzzles and storytelling.
Iain Standen, Chief Executive Officer of Bletchley Park Trust, said "Once we'd seen both the Adult Tour and the quirky Children's Tour, we were absolutely convinced that we had made a good choice."