Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

In a sweeping decision in favor of digital privacy, the Supreme Court ruled Wednesday that police almost always need a warrant to search a person’s cellphone, even in the case of someone placed under arrest.

In an unanimous decision, the court ruled against the Obama administration.

Sign up for breaking news alerts from NBC News

The usual law is that police can search anything on a person when they make an arrest. Opponents argued that smartphones were different because they hold such vast and personal stores of information.

“Modern cell phones are not just another technological convenience,” Chief Justice John Roberts wrote for the court. Elsewhere in the decision, he said that phones are so pervasive that “the proverbial visitor from Mars might conclude they were an important feature of human anatomy.”

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

But technological advances do not make such information less worthy of the Fourth Amendment protection against unreasonable search and seizure, Roberts wrote.

“Our answer to the question of what police must do before searching a cell phone seized incident to an arrest is accordingly simple — get a warrant,” he wrote.

The case concerned a man named David Leon Riley, who was pulled over in San Diego five years ago for driving with an expired license. When police found guns in his car, they arrested him for carrying concealed weapons.

Police then discovered pictures and videos on his Samsung phone, which led to charges that he took part in violent gang-related crimes.

The court suggested that police could still move ahead without a warrant in extreme circumstances — for example, a suspect texting someone who might detonate a bomb, or in the case of a kidnapper who might have information about the child’s location on his phone.

Those special circumstances can be evaluated by a court after the fact, the court pointed out.

The Obama administration had argued that cellphones can be searched just like anything else carried by someone who’s arrested. And the court acknowledged that its decision could have an impact on police’s ability to fight crime.

But warrants, Roberts wrote, are an important part of the machinery of government, not an inconvenience.

— Pete Williams