The High Court has ruled that the Corrections Department must pay compensation to former prisoners held for longer than they should have been.
Earlier this year the Supreme Court ruled the Department failed to factor in time spent in custody on remand when calculating Michael Marino's release date.
Marino was jailed for four months longer than he should have been and is seeking tens of thousands of dollars in compensation.
At a subsequent High Court case the Crown argued the Supreme Court ruling should only apply to future cases.
However in today's judgment, Justice Simon France said that would be a "significant milestone in New Zealand legal history" and a departure from the traditional approach to such matters.
He said that would mean the Supreme Court made such a ruling for the first time in New Zealand without mentioning it was doing so, something he described as "sufficiently unlikely as to not merit further comment".
Justice France said it was open to Corrections to ask the Supreme Court during the hearing to rule its judgment would only apply to future cases.
"I consider that if the Chief Executive wanted the Supreme Court judgment to have prospective effect only, it was incumbent on him to ask [it] to take that step and not raise it for the first time in subsequent civil proceedings".
Justice France said the main driver of Corrections' opposition to paying compensation to those unlawfully detained appeared to be the perceived unfairness of that.
But he said it was wrong to treat the matter as if Corrections' chief executive were a private individual.
"It is the State which [holds] the power to keep people in jail, and properly recognises it must have lawful authority to do so."
"The right not to have one's liberty removed, other than with lawful authority, is a key plank of our society and one of its most important and fundament rules."
Justice France also observed that fairness was always a matter of perception and being locked up for 127 days might also seem unfair to Michael Marino.
He said Corrections' argument that the detentions were lawful was foreclosed by the Supreme Court decision, and the prisoners were entitled to compensation.
Marino's lawyer Douglas Ewen sais Corrections had access to Parliament and should have acted earlier if it was concerned about the sentence calculation issue.
"They could have [raised] this back in 2003 when it was first aired in the Court of Appeal. They didn't do so, so it's not appropriate to cry foul in 2016 when the problem was largely of their own making."
A case about how much compensation will be paid is likely to go before the High Court in the new year.
In October, Corrections Minister Judith Collins said thousands of prisoners could potentially be affected by the release date error.
At the time, former Prime Minister John Key said whether compensation would be considered for affected inmates was uncertain and Parliament could pass retrospective legislation to rule out payments.
Ms Collins said today she was still awaiting advice from her Department, regarding whether law changes were needed to clarify the way in which prison term end dates were calculated.
Her office said no decisions had yet been made about legislative change, as the Corrections Department was still considering the implications of the Supreme Court decision.
Corrections refused to comment on today's High Court decision, saying parts of the case were still to be considered by the Court.
However, it said its priority had been to identify, assess and review current prisoners affected by the Supreme Court's judgement and adjust their release dates.
The group numbers about 500 prisoners not yet due for release, but whose release dates have been revised.