Canada's constitution bars authorities from forcing internet providers to turn over the identities of customers without a warrant, the Supreme Court ruled in a decision that better protects online anonymity.
The court handed down a unanimous ruling in the case of Matthew Spencer, convicted of possessing child pornography by a Saskatchewan provincial court.
Privacy advocates say the ruling makes unconstitutional a Conservative government bill currently before Parliament that would broaden the ability of police to monitor online traffic.
The legislation, which would amend existing laws covering search warrants and other investigative techniques, is intended to combat cyberbullying, but critics say it would allow excessive online spying.
Spencer used his computer to store hundreds of explicit images and videos of children.
The court said police effectively conducted a search without a warrant when they requested and received subscriber information for the account from Shaw Communications, the internet provider.
Without the information gleaned from that search, the court said police would not have obtained a warrant to physically search Spencer's property.
The court said web surfers had a reasonable expectation of privacy that was breached by the police request.
The OpenMedia.ca lobby group said the ruling vindicated its position that the Conservative government's online legislation, Bill C-13, is irresponsible.
Bob Dechert, parliamentary secretary to the minister of justice, said the government would review the decision.
"We will continue to crack down on cyberbullies and online criminals who work against and make our children and all Canadians unsafe," Dechert said.
The bill would introduce the new crime of "non-consensual distribution of intimate images". It was spurred partly by the suicide of Nova Scotia teenager Rehtaeh Parsons, the victim of an alleged sexual assault.
Photos of the attack were circulated online.