NICOLA Sturgeon has apologised "categorically, unequivocally and wholeheartedly" to gay men convicted under historic sexual offences who will now receive an automatic pardon.

Publishing a Holyrood bill which will also allow the men to have convictions scrubbed from criminal record checks, the First Minister said it would address a long-standing injustice.

The Historical Sexual Offences (Pardons and Disregards) (Scotland) bestows a “symbolic” pardon on all gay and bisexual men convicted of activity which is no longer illegal.

Herald View: Apology is just one step in journey to gay equality

Homosexual activity between consenting male adults was still a criminal offence in Scotland until 1980, despite it being decriminalised in England and Wales in 1967.

It then took until 2001, two years after the creation of the Scottish Parliament, for the age of consent to be reduced from 21 to 16, the same as for heterosexuals.

Around 50 to 100 men a year were prosecuted in Scotland for “gross indecency” and other offences, although a requirement for corroboration meant fewer were ultimately convicted.

There has never been a criminal offence for sex between women.

Ms Sturgeon told MSPs it was shocking that well within her lifetime "hundreds of people in Scotland were liable to be convicted as criminals simply for loving another adult."

She said the Bill would right a “historic wrong” but more than legislation was called for.

She said: “A pardon is of course the correct legal remedy to apply for the convictions we are talking about, but the term pardon might still - to some people - imply parliament sees them as having done something wrong. However, as all of us know, that is not the case here.

“The simple fact is that parliamentarians over many decades supported or at the very least accepted laws that we now recognise to have been completely unjust.

"So today as First Minister I categorically, unequivocally and wholeheartedly apologise for those laws and for the hurt and the harm that they caused to so many.

"Nothing that this parliament does can erase those injustices but I do hope that this apology, alongside our new legislation, can provide some comfort to those who endured injustices."

Herald View: Apology is just one step in journey to gay equality

A recent UK law grants a pardon to men in England and Wales if they apply for one.

The Scottish Bill goes further by making a pardon automatic to the living and posthumously.

However it also makes clear “the effect of the pardon is symbolic”, acknowledging past laws were discriminatory, and does not reverse convictions or pave the way for compensation.

The legislation also enables men to apply for past convictions to be “disregarded” so they no longer appear in enhanced criminal record checks, which could affect their job prospects.

The government estimates there will be three successful disregard applications a year.

Former Scottish Labour leader Kezia Dugdale, who came out in 2016, congratulated Ms Sturgeon and the government on the measures.

She said: “It takes a deep breath and a big heart to say sorry for mistakes of the past.”

She added: “We can not risk complacency, and upholding anti-discriminatory laws is critical. Today is a landmark day in Scotland's LGBT history."

Scottish Tory leader Ruth Davidson said: “My hope for those men and their families is that they now feel a weight lifted and that as well as criminal records formally being wiped clean, any lingering sense of legal stigma, any last shadow of unfair disgrace, is firmly banished.”

Herald View: Apology is just one step in journey to gay equality

Scottish LibDem leader Willie Rennie said people should reflect in the “wasted potential and lost achievements of those men whose lives were limited or tragically cut short because of this injustice. People were imprisoned and fined. Lives and families in many cases ruined.

“Our country is poorer for the limits we placed on those men’s freedom.

“It is right that Parliament stands together to apologise for that.”

Gay rights campaigner Derek Ogg QC said: “It's Scotland at peace with itself.”