The First Minister will apologise on behalf of the Scottish Government to all men convicted of now-abolished gay sexual offences.
Nicola Sturgeon will make the apology at Holyrood on Tuesday November 7 to coincide with the publication of new legislation to provide an automatic pardon to all those affected.
The legislation was promised by Sturgeon when she presented her programme for government in September.
It will enable people to apply to have such convictions removed from central criminal conviction records.
A Scottish Government spokesman said: “The First Minister will give a statement of apology to those convicted prior to 2001 under discriminatory laws against same-sex sexual activity that is now legal.
“The apology will be made on behalf of the Scottish Government for the treatment of homosexual men under previous governments and will coincide with the introduction of legislation to provide people convicted under these laws an automatic pardon.
“The Bill will right a historic wrong and give justice to those who found themselves unjustly criminalised simply because of who they loved.”
The legislation was first confirmed by Justice Secretary Michael Matheson in October last year.
He announced plans for automatic pardons just days after similar legislation was scuppered at Westminster.
The private member’s bill would have pardoned all men living with UK convictions for same-sex offences committed before the law was changed.
However, the UK Government, which has its own plans for posthumous pardons, “talked out” the bill in the Commons, resulting in it falling at its first parliamentary hurdle.
Tim Hopkins, director of the Equality Network, said: “The apology is important because it shows that it was the discriminatory laws that were wrong, and not the consensual relationships that were made criminal by those laws.
“We look forward to seeing the detail of the bill. If it implements the policy announced by the Scottish Government, it will be a hugely important statement that Scotland regrets the discrimination of the past, and now considers its LGBTI people to be fully equal citizens who deserve equal respect.
“It will also be of direct practical importance to people who currently have one of these convictions show up on criminal record checks for jobs or volunteer posts.”
Green MSP Patrick Harvie said: “The legal exoneration of people convicted under unjust laws is long overdue and I’m pleased that the First Minister feels that it’s appropriate to make an apology on behalf of Scotland at the same time.”