A raid on the mansion of internet tycoon Kim Dotcom was legal, a New Zealand court has ruled.
Mr Dotcom's home was searched and items were seized in January 2012, at the request of US authorities who accuse the 40-year-old of copyright theft.
The decision might increase the likelihood that Mr Dotcom will be extradited to the US.
However, the court did agree that the investigators' cloning of electronic evidence had been unlawful.
Authorities had made copies of information found on laptops and hard drives seized at Mr Dotcom's house, near Auckland.
He stands accused of instigating piracy on a massive scale by being the owner of Megaupload, a file-storage website.
The US Justice Department alleges that Mr Dotcom's site cost film studios and record companies $500m (£300m).
His defence centres on the notion that it was the responsibility of the site's users not to upload copyrighted material - and that the owners of such sites should not be held accountable.
Mr Dotcom's legal team said it intends to contest the appeal court's decision.
The raid, and events leading up to it, have been a point of controversy in New Zealand, both legally and politically.
Mr Dotcom has launched legal action against the government for its role in the raid.
Prime Minister John Key apologised to Mr Dotcom for what were described as "basic errors" by intelligence services in collecting information, on behalf of the US, before the raid.
Opposition parties called for further independent investigations.
And Mr Dotcom, while not able to stand himself due to not being a New Zealand national, pledged to start his own political group - the Internet Pary - to "activate non-voters, the youth, the internet electorate".