Gay men who were convicted of same-sex offences in Scotland before laws against homosexuality were dropped are to receive full pardons.
The BBC understands the Scottish government will announce a new bill next week.
If approved in parliament it would mean that all convicted gay men in Scotland would receive the formal pardon.
Men still living would also be able to apply for a "disregard" to remove convictions from their record.
This would need to applied for, in order to check that offences are not ones which are still illegal such as non-consensual sex and sex with someone under 16.
However, the Scottish bill will not require anyone to apply for a pardon.
It would be different from the new legislation in England and Wales which only "automatically" pardons those who died before February this year.
The law would only apply to men because gay women were not criminalised.
The Westminster government announced in October last year it was to introduce a so-called "Turing law" giving posthumous pardons to gay and bisexual men convicted of now-abolished homosexual offences such as gross indecency with another man and buggery.
It is named after World War Two code-breaker Alan Turing, who was pardoned in 2013.
Mr Turing's work during the war helped break German codes, but he was convicted of "gross indecency" in 1952 and was chemically castrated.
The Sexual Offences Act decriminalised homosexual acts between men over 21 in England and Wales in 1967, but the law in Scotland was not changed until 1980. Same-sex sexual activity was not equalised until 2001.
It is expected up to 5,000 men in Scotland, living and dead, could be included in the provisions of the new bill.
It is likely to be part of a bill looking at which historical convictions could be wiped from people's criminal records and after how long.
Last year Scottish Justice Secretary Michael Matheson said he wanted to see an "automatic formal pardon" for those convicted under these "discriminatory" laws, calling it an "injustice" he needed to address.
The bill is expected to receive cross-party support in Holyrood.
No longer illegal
Tim Hopkins, director of the Equality Network, told the BBC that the Scottish legislation would be significantly different to that already passed in England and Wales.
He said: "We don't know exactly how many people this will apply to.
"In England and Wales the figure was put at 50,000 so normally it would be about 10% of that but it is difficult to tell because prosecution policy tended to be somewhat less strict here.
"Certainly we are talking about many hundreds of people prosecuted for things that are no longer illegal. And it will apply also to people prosecuted 300 and more years ago."
"The problem in England is that if you were still alive on 1 February this year then there is no provision for an automatic pardon.
"The only way to do it there is to apply via a detailed application form which many people feels adds insult to injury."
Bill in two parts
Mr Hopkins said he expected the Scottish bill to be in two parts.
The first would be a formal pardon for every man convicted under homosexuality laws.
The second would be a conviction "disregard" for men still living whose records are problematic. This would need to be applied for.
Mr Hopkins said: "For example anybody who wants to volunteer or do a job which requires a disclosure check might want to apply to the Scottish government for a conviction disregard.
"It means filling in an application and then the government will check the offences against those which are no longer legal.
"What we don't want is for something that is still illegal to be removed."
He added: "England and Wales have already introduced a conviction disregard but only about 200 or 300 people have applied and only about 150 have been granted.
"Why is that number so small? Many people don't want to drag it all up again."
There was controversy in Westminster last year after an SNP member's bill on the issue was "talked out", with Theresa May's government preferring its own plans.
Separately, government officials have been working with Police Scotland to find a way to ensure past convictions no longer appear on criminal records, and to have convictions disregarded from centrally-held records.
The specific changes to the law at Westminster will pardon men who have since died, but thousands of living men with convictions will also be eligible for a pardon by applying to the Home Office.
SNP MP John Nicolson lodged a private members bill calling for blanket pardons for those still living, but the UK government said this could see people claiming pardons for acts that are still illegal.
Campaign group Stonewall supported Mr Nicolson, pointing out that his bill "explicitly" excluded pardoning anyone convicted of offences that are still illegal, such as non-consensual sex and sex with someone under 16.
A Scottish government spokeswoman said: "The first minister will announce the Scottish government's legislative plans for 2017-2018 when she publishes the Programme For Government on Tuesday.
"However, as the cabinet secretary announced last year, the Scottish government will introduce legislation that will, if approved by parliament, provide for a pardon for those convicted under now repealed discriminatory laws for activity that would now be legal, and unlike the UK government system, this will not require anyone to apply for such a pardon.
"The pardon will apply to both the living and posthumously.
"The Scottish government will also introduce a scheme to allow people with such convictions to apply to have them 'disregarded' so they would never show up on a criminal record check."