New Zealand's parliament has passed legislation to erase historical convictions for engaging in gay sex, saying the bill would help right past injustices.
Homosexuality was decriminalised in New Zealand in 1986, but men who were convicted before then still had the offence listed on their official records.
Politicians unanimously passed a bill allowing those convicted of consensual homosexual sex to have their records expunged.
"I would like to apologise again to all the men and members of the rainbow community who have been affected by the prejudice, stigma and other negative effects caused by convictions for historical homosexual offences," Justice Minister Andrew Little said.
"This bill sends a clear signal that discrimination against gay people is no longer acceptable, and that we are committed to putting right wrongs from the past."
The justice department said the convictions related to three offences that were dropped in 1986 - sodomy, indecency between males and keeping a place of resort for homosexual acts.
It estimates about 1,000 people will be eligible to apply to have their records cleared when the scheme takes effect next year.
To qualify, the sex that led to the conviction must have been consensual and taken place between those aged 16 years or older.
The repealed laws were first introduced in 1908. Under the new scheme, family members can also apply to have the records of a deceased relative cleared.
The scheme refers to men because the old laws specifically banned sex between males. Lesbianism was not illegal, although gay women also suffered social discrimination.
New Zealand passed laws banning discrimination against gays in 1993, and in 2013 became the first country in the Asia-Pacific region to legalise same-sex marriage.
Britain last year enacted "Turing's Law", giving a blanket posthumous pardon to almost 50,000 men convicted under old laws in England and Wales.
Named after the World War II code-breaker and mathematician Alan Turing, it also allows living people to have their convictions erased, although they must apply individually.
Mr Turing received a posthumous pardon from Queen Elizabeth II in 2013 over a conviction in 1952 for gross indecency with a 19-year-old man, triggering calls for a blanket pardon for other men.
He did not go to prison but was chemically castrated, and died of cyanide poisoning in an apparent suicide two years later.
A number of Australian states, including New South Wales, Victoria and South Australia, have also quashed historical convictions for homosexuality.
Germany went a step further last year when it not only erased the convictions of 50,000 gay men sentenced under a Nazi-era law, but also offered compensation to some survivors.