The ruling yesterday is the third embarrassment in the case for Crown lawyers, who are representing the United States in the arrest, seizure and extradition process.
It has previously emerged they used the wrong type of restraining order to seize Dotcom's funds and seizing his property without notice when he should have been given the chance to challenge the seizure.
Then it emerged the Crown knew it was using the wrong order while the raid was in progress.
During the raid, police seized computers, phones and anything which appeared to contain a hard drive - a total of 135 items.
Ms Winkelmann said the search warrant was too broad in the way it described what could be taken.
"These categories of items were defined in such a way that they would inevitably capture within them both relevant and irrelevant material. The police acted on this authorisation.
"The warrants could not authorise seizure of irrelevant material, and are therefore invalid."
She added: "The police relied on invalid warrants when they searched the properties and seized the various items. The search and seizure was therefore illegal."
She noted that even if she was wrong about the validity of the warrants, it was clear police had "exceeded what they could lawfully be authorised to do" because they continued to hold irrelevant material.
She said police faced difficulties executing the search warrants in a lawful manner because they were not the investigating officers with knowledge of the operation.
It emerged during the hearing this month that FBI staff copied some of the seized hard drives at the police electronic crime lab in South Auckland and sent the copies back to the US.
This prompted Dotcom's lawyer, Paul Davison, QC, to say cloning the hard drives had "subverted" his client's rights.
The four accused wanted a declaration the removal of the clones from New Zealand was unlawful.
They also wanted an independent lawyer to decide which of the items seized were relevant to the investigation.
Ms Winkelmann acknowledged the copies had been sent to the US without the consent of Dotcom and his associates, but would not go anyfurther.
She said she wanted the Crown and Dotcom's lawyers to work out a solution before a hearing scheduled for July 4.
The police have previously defended the surprise raid which used helicopters and the special tactics group armed with automatic weapons.
Officials seized Dotcom's collection of more than 20 luxury cars, wife Mona's jewellery and expensive art works. More than $10 million held in New Zealand accounts was also seized.
Police said they were considering the judgment and were in discussions with Crown Law to determine what further action might be required.
Attorney-General Christopher Finlayson's office said he would not comment on matters before the court.
Simpson Grierson partner Greg Towers said last night the four men were "very happy" with the decision and were considering their remedies.
Click here to read the complete decision in Kim Dotcom case