World War Two code-breaker Alan Turing was given a posthumous pardon in 2013
Gay and bisexual men convicted of now-abolished sexual offences in England and Wales are to receive posthumous pardons, the government has announced.
Thousands of living men convicted over consensual same-sex relationships will also be eligible for the pardon.
Lib Dem peer Lord Sharkey, who proposed the amendment to the Policing and Crimes Bill, said it was "momentous".
It follows the pardoning of World War Two code-breaker Alan Turing for gross indecency in 2013.
Under the amendment – dubbed "Turing law" – deceased people who were convicted of sexual acts that are no longer deemed criminal will receive an automatic pardon.
Media captionThe great-niece of Alan Turing, Rachel Barnes, on posthumous pardons for gay men.
Anyone living who has been convicted of such offences could already apply through the Home Office to have the offence wiped from their criminal records.
But now, if the Home Office agrees that the offence is no longer an offence under current law, they will automatically be pardoned.
Justice Minister Sam Gyimah said it was "hugely important that we pardon people convicted of historical sexual offences who would be innocent of any crime today".
Lord Sharkey said he understood why some people may not want a pardon, or may "feel that it's wrong".
But, he told BBC Radio 4's Today programme, "a pardon is probably the best way of acknowledging the real harm done by the unjust and cruel homophobic laws, which thankfully we've now repealed. And I do hope that a lot of people will feel exactly the same way".
He said of the 65,000 men convicted under the laws, 15,000 are still alive.
'I will not accept a pardon'
Media captionGeorge Montague: "I want an apology … to accept a pardon means you accept that you were guilty."
George Montague was convicted in 1974 of gross indecency with a man. He says he wants an apology – not a pardon.
"To accept a pardon means you accept that you were guilty. I was not guilty of anything. I was only guilty of being in the wrong place at the wrong time," he told BBC Newsnight.
"I think it was wrong to give Alan Turing – one of the heroes of my life – a pardon.
"What was he guilty of? He was guilty of the same as what they called me guilty of – being born only able to fall in love with another man."
He added: "If I get an apology, I will not need a pardon."
He added that there "never should have been an offence of gross indecency".
"It didn't apply to heterosexuals. Heterosexuals could do what they liked, in the doorways, in passageways, the back of their car.
"It only applied to gay men. That's not right, surely?"
The Sexual Offences Act decriminalised private homosexual acts between men aged over 21 in England and Wales, in 1967.
The law was not changed in Scotland until 1980, or in Northern Ireland until 1982.
Announcing the new plan, Mr Gyimah said the government would support Lord Sharkey's amendment to the Policing and Crime Bill – which would apply to England and Wales, but not Scotland and Northern Ireland as the Justice Department does not cover devolved administrations.
Relatives of Alan Turing petitioned for historical convictions to be quashed
In 2013, the posthumous royal pardoning of Turing led to calls for wider pardons, and the launch of a petition in 2015.
The petition gathered almost 640,000 signatories, including the actors Stephen Fry and Benedict Cumberbatch, who played Turing in the film about the enigma code, The Imitation Game.
The charity Stonewall, which campaigns for lesbian, gay, bisexual and transgender people, said it has begun discussions with the Scottish government to allow similar procedures to be introduced in Scotland.
In Northern Ireland, the Rainbow Project, also a charity and campaign group, met with the justice minister in August to discuss the law around historical convictions.
Turing, the Bletchley Park code-breaker, was convicted in 1952 of gross indecency with a 19-year-old man.
He was later chemically castrated and died in 1954 after poisoning himself with cyanide.
His pardon, almost 60 years later, followed a Private Member's Bill introduced by Lord Sharkey.
The Lib Dem peer said it was "a momentous day for thousands of families up and down the UK".
He said: "It is a wonderful thing that we have been able to build on the pardon granted to Alan Turing during the coalition."
The Turing Bombe helped decipher messages sent by Germany's Enigma machines
Turing's great niece Rachel Barnes said the moment Turing's family heard he was to receive a pardon was "absolutely tremendous".
She told the Today programme: "Alan Turing just so, so deserves this. To think that this is the man who cracked the enigma code and saved countless of millions of lives during World War Two and to think of the treatments that he went through at the hands of the government in 1952 is still unbelievable to us."
She said that the family has always highlighted his achievements rather than the fact he was a gay man.
She added: "Because we shouldn't be thinking about his sexuality, we should really be focusing on the successes of this incredible man in history who has done so much for the country and for the world".
Private Member's Bill
The government has said it will not be supporting a separate Private Member's Bill on the subject – introduced by SNP MP John Nicolson – which is set to be debated on Friday.
Mr Nicolson, the MP for East Dunbartonshire, has proposed a blanket pardon for those still living, without the need to apply for their criminal records to be cleared by the Home Office.
Mr Gyimah said such a move could see people claiming pardons for acts that are still illegal.
"This would cause an extraordinary and unnecessary amount of distress to victims," he added.
Paul Twocock from Stonewall welcomed the announcement but said it supported Mr Nicolson's Private Member's Bill.
Mr Twocock said the bill "explicitly" excluded pardoning anyone convicted of offences that would still be illegal today, including non-consensual sex and sex with someone under 16.