WELLINGTON, New Zealand — New Zealand lawmakers unanimously apologized Thursday for the “tremendous hurt and suffering” of hundreds of men who were convicted of homosexuality during the years it was treated as a crime.

Parliament took the rare step of issuing a formal apology to all those unfairly convicted under the antiquated laws. Lawmakers also approved the first stage of a bill that will allow the men to have their criminal records wiped clean, legislation that comes four years after the South Pacific nation legalized same-sex marriage.

The measures were passed with unanimous approval among lawmakers from various political parties.

Justice Minister Amy Adams talks to reporters Thursday, July 6, 2017, in Wellington, New Zealand. Nick Perry / AP

“Today we are putting on the record that this House deeply regrets the hurt and stigma suffered by the many hundreds of New Zealand men who were turned into criminals by a law that was profoundly wrong, and for that we are sorry,” said Justice Minister Amy Adams.

She said it was unimaginable today that consensual sex between adults would be considered criminal.

The Morning Rundown Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“It is never too late to apologize,” Adams told lawmakers. “While we cannot ever erase the injustice, this apology is a symbolic but important act that we hope will help address the harm and right this historic wrong.”

The government estimates about 1,000 men will be eligible to have their convictions quashed. Most were prosecuted after 1965 and before 1986, when New Zealand decriminalized homosexuality. They were convicted of crimes such as indecency, sodomy and providing a place for homosexual acts.

RELATED: New Zealand Men Convicted of Gay Sex to Have Records Wiped

Those with convictions will need to apply to have their cases assessed because the law didn’t distinguish between consensual and nonconsensual gay sex, Adams said.

Sex between women was never explicitly illegal under New Zealand law.

Opposition lawmaker Grant Robertson quoted from a man who was forced to resign from the Army because of his sexuality.

“This conviction still leads, after 53 years, to self-hatred, worthlessness, unjustified guilt and shame,” the unnamed man said, according to Robertson. He said the law change would allow the man to feel some dignity in his final years.

RELATED: 15 Best Countries for LGBTQ Expats

Robertson, who is openly gay, said he stood on the shoulders of those who had been convicted.

“The fact that I, as a gay man, can be out and proud and a member of parliament is but a small tribute to you,” he said.

Adams has said the convicted men will not receive any compensation, although Robertson said that should be reconsidered.

Follow NBC Out on Twitter, Facebook and Instagram