Former Navy Commodore Kevin Keat has had all of his convictions quashed after being court martialled over his sexual affair with a civilian.
In 2010 he was made assistant chief of personnel, overseeing the move to swap military staff for cheaper civilian workers.
But in 2008, Keat, 55 and married, had begun having sex with one of those civilian staff.
Last year guilty findings were delivered on five charges after he was found to have besmirched the New Zealand Defence Force, from which he was subsequently dismissed.
Yesterday's Court Martial Appeal Court ruling overturned those convictions including two of prejudice to service discipline and one each of failing to comply with orders, having an unprofessional close relationship and using threatening language.
Keat's lawyer Michael Bott said the complainant had a history of bullying, intimidation and complaints and the decision was the correct one as a matter of law.
The name of the complainant and her daughter was suppressed.
The decision found Chief Judge Chris Hodson QC had failed to properly direct military personnel on the issue of Keat's state of mind and had failed to properly summarise the defence case.