The U.S. Supreme Court on Wednesday ruled that police officers usually need a warrant before they can search the cellphone of an arrested suspect, a major decision in favor of privacy rights at a time of increasing concern over government encroachment in digital communications.

In an opinion written by Chief Justice John Roberts, the court said there are some emergency situations in which a warrantless search would be permitted. But the unanimous 9-0 ruling goes against law enforcement agencies including the U.S. Department of Justice, which wanted more latitude to search without having to obtain a warrant.

"We cannot deny that our decision today will have an impact on the ability of law enforcement to combat crime," Roberts wrote, adding that the right to privacy "comes at a cost."