OTTAWA -- A divided Supreme Court of Canada has ruled that police can conduct a limited search of suspect's cellphone without getting a search warrant, but they must follow strict rules.

By a 4-3 margin, the court said in a precedent-setting ruling that the search must be directly related to the circumstances of a person's arrest and the police must keep detailed records of the search.

Three dissenting justices said the police must get a search warrant in all cases except in rare instances where there is a danger to the public or the police, or if evidence could be destroyed.

It is the first Supreme Court ruling on cellphone privacy, an issue that has spawned a series of divergent lower court rulings.

The high court dismissed the appeal of the 2009 armed robbery conviction of Kevin Fearon, who argued unsuccessfully that police violated his charter rights when they searched his cellphone without a warrant after he'd robbed a Toronto jewelry kiosk.

The court agreed that the police had in fact breached Fearon's rights, but the evidence against him on his cellphone should not be excluded.

"The police simply did something that they believed on reasonable grounds to be lawful and were proven wrong, after the fact, by developments in the jurisprudence," Justice Thomas Cromwell wrote for the majority.

"That is an honest mistake, reasonably made, not state misconduct that requires exclusion of evidence."

Cromwell said the court was trying to strike a balance between the demands of effective law enforcement and the public's right to be free of unreasonable searches and seizures under Section 8 of the Charter of Rights and Freedoms.

"In my view, we can achieve that balance with a rule that permits searches of cellphones incident to arrest, provided that the search -- both what is searched and how it is searched -- is strictly incidental to the arrest and that the police keep detailed notes of what has been searched and why."

The ruling laid out detailed criteria to guide police.

The arrest must be lawful, and the search must be "truly incidental to the arrest" and "based on a valid law enforcement purpose," it said.

The ruling defined valid law enforcement as: protecting the police, accused or the public.

That includes preserving evidence and discovering new evidence, "including locating additional suspects, in situations in which the investigation will be stymied or significantly hampered absent the ability to promptly search the cellphone incident to arrest."

Moreover, the ruling said a phone can subjected to a warrantless search if the "nature and the extent of the search are tailored to the purpose of the search" if police "take detailed notes of what they examined on the device and how it was searched."

That lack of proper note-taking was the one flaw the high court identified in Fearon's arrest, but it said that wasn't enough to exclude the evidence that was gathered from his phone.

After police arrested Fearon, they found a relevant draft text message that referred to "jewelry" and photographs, including the handgun used the robbery.

"We did it," the text message read in part.

Police later obtained a search warrant but found nothing more useful on the phone.

The court said the evidence the officers presented in court about the initial search was unsatisfactory. One officer testified that he "had a look through the cellphone" and another said he did "some quick checks" for about two minutes.

Beyond that, the court concluded, the police "were not able to provide many specifics."

Still, the high court allowed that evidence to stand -- upholding Fearon's conviction -- and agreed with the original trial judge's finding that excluding it would "would undermine the truth-seeking function of the justice system."

Writing for the three dissenters, Justice Andromache Karakatsanis said police should need a warrant in all cases to search a cellphone.

"The intensely personal and uniquely pervasive sphere of privacy in our personal computers requires protection that is clear, practical and effective," she wrote.

She added the court's majority ruling had proposed an "overly complicated template" for police to follow.

"Fundamentally, my colleague's approach puts the balancing decision in the hands of the police," Karakatsanis wrote.

"I doubt not that police officers faced with this decision would act in good faith, but I do not think that they are in the best position to determine 'with great circumspection' whether the law enforcement objectives clearly outweigh the potentially significant intrusion on privacy in the search of a personal cellphone or computer" she added.

"If they are wrong, the subsequent exclusion of the evidence will not remedy the initial privacy violation."