Politicians have welcomed the pardoning of thousands of gay and bisexual men by the Scottish Parliament.

MSPs voted unanimously to give automatic pardons to gay men convicted under historical discriminatory legislation and enabling them to have any such convictions effectively scrubbed from criminal records.

Justice Secretary Michael Matheson said the legislation marks a "proud day for Scotland".

The Historical Sexual Offences (Pardons and Disregards) Bill will automatically pardon gay men convicted under historical discriminatory laws and will also allow them to apply for past convictions of this nature to be legally disregarded or removed from criminal records.

Private same-sex activity between two men aged over 21 was illegal in Scotland until 1981 and the age of consent for gay men was reduced to 16 in 2001.

West Scotland MSP and Scottish Labour equalities spokesperson Mary Fee MSP said she also secured a commitment from the Scottish Government to write to families of deceased men who were criminalised apologising and posthumously pardoning them.

In remarks at the close of debate on the bill, Ms Fee said: “It is evident that the legacy of convictions, fines and warnings as a result of the discriminatory laws that prohibited sexual activity between two men in Scotland has had an enduring, damaging and hurtful impact on thousands of men’s lives.

“The bill also says much about the country that we aspire to be. It makes an important statement that Scotland is a country that firmly rejects discrimination and celebrates our LGBTI community, and supports them to be full and equal citizens who are treated with respect.”

Speaking after the vote, the MSP added: “We cannot rest on our laurels as discrimination and inequality remain all too prevalent in society and we must continue to tackle them.”

Ross Greer, Green MSP tweeted after the vote: "Proud day to be an MSP."

Colin Macfarlane Director Stonewall Scotland said: “The First Minister’s apology is an important moment, both for the LGBT community and for Scotland. Gay and bi men in Scotland were criminalised for a very long time simply for who they were and who they loved. Today’s apology will give a great deal of comfort to many who were unjustly prosecuted, and will help draw a line, once and for all, under a dark period in Scotland’s history.

"As well as the hurt and damage that came with being prosecuted for these crimes, many men have carried a criminal record with them their whole lives as a result. We’re very pleased to see that this bill includes provision for these unjust convictions to be wiped from criminal records, and a pardon, both for those living and deceased.”