A High Court judge has ruled that police search warrants used to seize property from Kim Dotcom were illegal.
Justice Helen Winkelmann found that the warrants used did not properly describe the offences to which they were related.
The FBI agents had been accused of underhanded behaviour by Dotcom's lawyers in the High Court after they secretly copied data from his computers and took it overseas.
Justice Winkelmann has also ruled it was unlawful for copies of Dotcom's computer data to be taken offshore.
Police said they were considering the judgment and were in discussions with Crown Law "to determine what further action might be required".
Police would not make any further comment on the judgement until then.
Dotcom spoke at a meeting at his local Coatesville Settlers Hall tonight, but entered through a back door and would not speak to reporters.
A spokesman for Dotcom said the internet millionaire was "pleased" with the ruling, but he would not be making any further comment on the decision as appeals are likely, TVNZ reported.
Justice Winkelmann ordered that no more items taken in the raids could be removed from New Zealand, and instructed the attorney-general to return clones of the hard drives held by New Zealand police.
She said the search warrants were invalid because they were general warrants which lacked specificity about the offence and the scope of the items to be searched for.
Without a valid warrant, police were trespassing and exceeded what they were lawfully authorised to do.
Justice Winkelmann said no one had addressed whether police conduct also amounted to unreasonable search and seizure, but her preliminary view was that it did.
Detective Inspector Grant Wormald said that although police were able to decide what documents and digital storage devices should be seized, they had no request from the Central Authority to proceed on that basis. His understanding was that the attorney-general would direct that the items seized would immediately be sent to the US to be examined there.
The judge said the domestic courts were the best place to determine compliance with domestic laws.
There were deficiencies in the description of the offences in the case. The warrants did not stipulate that the offences of breach of copyright and money laundering were offences under the law of the United States. They do not refer to any law that would allow the subject of the warrant to understand the offences.
This "would no doubt cause confusion to the subjects of the searches...they would likely read the warrants as authorising a search for evidence of offences as defined by New Zealand law".
The Megaupload founder's lawyer, Paul Davison QC, said the warrant provided inadequate definition of the offence. This meant that there was an inadequate definition of what was being searched for.
"Copyright can exist in many things," Justice Winkelmann said.
Police had said they had no intention of sorting items seized in the raid from the "relevant" to the "irrelevant" and would leave that to the FBI. However, the judge said that approach was not available to them. The law stated that only applicable items in the investigation could be sent to a foreign authority.
Dotcom had earlier questioned the legality of the search warrants police used to raid his mansion in January.
Davison told the High Court at Auckland last month that police carried out a sweep of electronic equipment. He alleged 135 data storage devices were taken during the police raid.
Dotcom, 38, is on bail awaiting an extradition hearing.
US authorities say he and his three co-accused - Mathias Ortmann, Fin Batato and Bram van der Kolk - used Megaupload and its affiliated sites to knowingly make money from pirated movies and games.
Dotcom is charged with multiple copyright offences.
Megaupload's lawyer, Willie Akel, last month told Auckland High Court that two FBI analysts flew to New Zealand on March 20 and reviewed seven hard drives of information.
The analysts cloned the computers in Manukau.