Mailley appealed the decision to the High Court, but Justice Rebecca Ellis backed the earlier decision and the appeal was thrown out.
Now, in a new ruling, the Court of Appeal has quashed the earlier extradition decisions.
Appeal judges ruled that the extradition case should have been brought by the Commonwealth of Australia, and not New Zealand Police, because of the "nation to nation nature" of the extradition process.
The error was deemed a "procedural technicality" rather than resulting in Mailley suffering any prejudice.
Previous decisions also failed to take into account Mailley's mental health problems and the fact he also suffers from heart disease.
Medical reports showed that Mailley has attempted suicide on several occasions, while he also suffered from bipolar disorder and post concussion syndrome arising from head injuries.
One doctor wrote: "It is my opinion, therefore, that there is a very real likelihood of Mr Mailley committing suicide either to avoid being returned to Australia, or after being returned there."
But while the appeal judges concluded that the reports were "overstated", with only one documented suicide attempt having arisen from an argument with his partner, not the extradition hearing, they concluded, "We agree it would be unjust for Mr Mailley to be extradited" without his health matters having been given proper consideration.
The case has now been sent back to the district court for a judge to consider whether it should be referred to the Minister of Justice because of Mailley's health.