Daniel Clinton Fitzgerald, 47, tried to kiss a stranger on Cuba St in Wellington and in the struggle made the unwanted contact on her cheek.
The woman's friend tried to intervene and Fitzgerald pushed her up against a shop window.
Convicted of the indecent assault and with two prior convictions for serious violent offences, the three strikes law required that the maximum penalty be handed down.
At sentencing, the Justice Simon France recognised the offending was at a level that would not usually result in prison time and that he had longstanding mental health issues.
Nonetheless, under the three strikes regime the seven-year term was imposed.
Fitzgerald had sought a discharge without conviction.
His defence lawyer Kevin Preston took the case to the Court of Appeal.
In the decision released today, Justices David Goddard and Denis Clifford acknowledged Fitzgerald's ability to control his behaviour was "severely compromised" by longstanding mental health conditions.
Section 106 of the Sentencing Act 2002 dictates that a discharge without conviction cannot be granted if by "any enactment applicable to the offence the Court is required to impose a minimum sentence".
The two judges had "striven to identify a tenable reading" of the law that would allow the courts to avoid imposing a sentence on Fitzgerald that breached of his NZBORA rights.
"We have reluctantly concluded that this course is not open to us."
But Justice David Collins offered a dissenting view and would have allowed the appeal.
"The direct and indirect consequences of a conviction are, in the circumstances of this case, out of all proportion to the gravity of Mr Fitzgerald's offending."
Fitzgerald's personal circumstances, including his psychiatric history, compounded the injustice of him being imprisoned for this offending, he said.
In 2018, Labour tried to repeal the three strikes law but ditched that plan because of objections by New Zealand First.