Internet tycoon Kim Dotcom's cash, cars and property were seized using a court order which should never have been granted.
A judgement 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.
Justice Potter said Mr 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 Mr Marshall applied for the "incorrect order".
Justice 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 Justice 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% of internet traffic - being pulled down and $200 million 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, his 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.
Ms Toohey enclosed new legal papers to seek a replacement restraining order and outlined five errors with the initial application.
Court papers showed Mr Marshall accepted the initial order "may well be a nullity".
However, the Crown submitted that new orders granted meant the previous errors did not matter as the property was still restrained.
Dotcom's legal team challenged the error, stating the seizure of the property was "unlawful".
Court papers show Dotcom's lawyer, William Akel. stating the belongings and fortune "must be released" because they were "unlawfully seized and restrained under the order".
A spokesman for the Attorney-general said Mr Finlayson was briefed on the issue, apparently in early February.
Dotcom's legal team was unwilling to comment on the decision.