Internet tycoon Kim Dotcom's cash, cars and property were seized using a court order which should never have been granted.
A judgment from Justice Judith Potter on Friday declared the restraining order "null and void" and having "no legal effect".
The blunder might now lead to the beleaguered internet mogul getting back everything that was stripped away in the surprise dawn raid on his mansion eight weeks ago.
Police commissioner Peter Marshall and the Government's legal advisers at the Crown Law Office have admitted making an embarrassing "procedural error" when filing documents to seize Dotcom's property.
Potter said Marshall's application for the restraining order had "confused" legal moves by opting for one in which Dotcom was not given a chance to mount a defence. It meant Marshall applied for the "incorrect order".
Potter said he had sought to correct the mistake after the raid by applying for the proper order, retrospectively listing assets already seized.
The new order had been granted on a temporary basis, but Potter said she would soon rule on whether the mistake meant the internet mogul should get his property back.
A briefing on the mistakes has been made to Attorney-General Chris Finlayson - who is also the minister in charge of the Crown Law Office.
It was his legal authority that was used by Crown Law to authorise the seizure of the goods, which was undertaken by police and the Official Assignee.
The raid led to Dotcom's Megaupload sites - which carried 4 per cent of internet traffic - being pulled down and $200m in assets seized. A fascinated public watched as officials took a string of luxury cars from the $30 million mansion in North Auckland where Dotcom, wife Mona and their three children lived.
The seizure left Dotcom with no finances to mount a legal challenge against claims he had overseen the biggest criminal copyright operation in history.
On January 30, Crown lawyer Anne Toohey wrote to the court to explain the wrong sort of restraining order had been applied for, saying a "procedural error" had occurred.
Toohey enclosed new legal papers to seek a replacement restraining order and outlined five errors with the initial application.
Court papers showed Marshall accepted the initial order "may well be a nullity".
However, the Crown submitted that new orders granted meant the previous errors didn't matter as the property was still restrained.
Dotcom's legal team, including Simpson Grierson senior partner Willie Akel, challenged the error, stating the seizure of the property was "unlawful".
Court papers show Akel stating Dotcom's belongings and fortune "must be released" because it was "unlawfully seized and restrained under the order".
A spokesman for the Attorney-General said Finlayson was briefed on the issue, apparently in early February.
Dotcom's legal team were unwilling to comment on the decision.
The move would be seen as a new victory for Dotcom. Earlier, Paul Davison QC had successfully over-turned the insistence Dotcom should be held in jail, rather than bailed, before an extradition hearing expected within six months.
But Dotcom is not guaranteed to get his property back.
Canterbury University professor Ursula Cheer said the law made allowances for mistakes and the case would only be fundamentally affected if Dotcom's lawyers were able to produce evidence showing a lack of good faith.
This was "so high profile, anything like this looks extremely bad," she said.By David Fisher @@DFisherJourno Email David