Sweeping police search warrants forcing telecom companies to turn over the cellphone records of thousands of innocent customers breach people's privacy and violate the Charter of Rights and Freedoms, an Ontario Superior Court judge has ruled.

The decision released Thursday says Canadians' mobile phone records should in principle remain private. In the decision, Justice John Sproat lays out guidelines so that police may only obtain a minimal amount of information about cellphone users directly relevant to their investigation.

Sproat was ruling in a case where police in Peel Region, west of Toronto, obtained a court order for the names, numbers, addresses and banking details of every mobile phone user whose signals were bouncing off various cellphone towers during a series of jewelry store robberies in early 2014.

Rogers and Telus challenged the court order as a breach of privacy saying it would have involved giving police information about more than 40,000 customers, nearly every one of them innocent. Telus officials told the court it was the "most extensive" police demand for customer data the company had ever received.

"We thought that crossed the line and was too broad and intrusive," said David Watt, chief privacy officer for Rogers Communications Inc., in a statement emailed to CBC News on Thursday. "We're glad the court agreed."

Peel police wanted the names, numbers, addresses and banking details of every mobile phone user whose signals were routed through various cellphone towers, but Rogers and Telus fought the request in court.

Sproat ruled that it is "improper for the police to seek irrelevant personal information" in their investigations.

"I have no hesitation in finding that the production orders were overly broad and that they infringed Section 8 (against unreasonable search and seizure) of the charter," wrote Sproat in the decision.

Guidelines for police

Sproat set out a series of guidelines for courts to follow when considering similar police requests in the future.

He said police should tailor their requests for call records to obtain only the minimal amount of information that is directly relevant to the investigation.

"For example, in this case a report on which telephone numbers utilized towers proximate to multiple robbery locations ... and not the personal information of more than 40,000 subscribers," wrote Sproat.

There is an issue concerning the privacy rights of hundreds of thousands of Canadians. - John Sproat, Ontario Superior Court justice

There is already concern among some police forces about Sproat's guidelines suggesting cell companies provide them with a report rather than raw data.

"I think that in some situations that might not be the best avenue," said Staff Sgt. Dan Richardson, the officer in charge of corporate communications for Peel Regional Police.

Richardson said in an interview with CBC News that the ruling means police will need to be specific about what they're searching for when they seek a court order for cell records, but overall it "still allows police the opportunity to work toward solving crime."

Case a 1st in Canada

Sukanya Pillay, the executive director of the Canadian Civil Liberties Association, said her group welcomes the decision because it recognizes that cellphone subscribers have legitimate privacy interests.

In an interview with CBC News, Pillay said the ruling makes it clear that police seizures of mobile phone records must comply with the charter. "They can't be mass surveillance, needle in a haystack searches," Pillay said.

Sukanya Pillay, executive director of the Canadian Civil Liberties Association, says the ruling protects the privacy of cellphone subscribers by preventing police from making what she calls 'needle in a haystack searches.' (Aaron Vincent Elkaim/Canadian Press)

University of Ottawa law professor Teresa Scassa said the guidelines limit how much personal information police can get their hands on in tower dumps.

"The judge makes it clear that the information that is sought by police should be really limited to the purposes of the investigation," Scassa said a phone interview with CBC News. "It shouldn't be a fishing expedition through all of the possible data that the police can extract from the telephone companies."

During the hearing into the case, lawyers for the attorney general of Ontario argued that Rogers and Telus should not be allowed to assert their customers' charter right to privacy, only their own corporate right to privacy. The judge rejected that.

"There is an issue concerning the privacy rights of hundreds of thousands of Canadians," he wrote. "To my mind, the choice is clear."

"The ministry is reviewing the decision and, as the matter is currently within the appeal period, we have no further comment," said Brendan Crawley, spokesman for the attorney general, in an email.

Sproat agreed in June 2014 to hear the charter challenge. At the time, he wrote that the case would be the first in Canada to test the constitutionality of tower dumps, and would have "significant implications" for the relationship between law enforcement and telecom companies.