The Justice Department suffered a digital-age defeat Friday at the Supreme Court, which sided with the privacy rights of cellphone users in a dispute over law enforcement tracking their movements.

In a 5-4 ruling, the court said law enforcement generally will need a warrant for such searches.

Chief Justice John Roberts cast the deciding vote.

At issue is whether the Constitution's Fourth Amendment requires a search warrant for the government to access a person's cellphone location history. It is the latest foray by the justices into how laws should be tailored to keep up with technological advances.

The stakes were enormous, since this judicial precedent could be applied more broadly, including government access to Internet, bank, credit card and telephone records.

Roberts in his opinion said going forward, warrants are needed.

“We decline to grant the state unrestricted access to a wireless carrier’s database of physical location information,” he wrote. “The fact that such information is gathered by a third party does not make it any less deserving of Fourth Amendment protection. The Government’s acquisition of the cell-site records here was a search under that Amendment.”

Roberts was supported by Justices Ruth Bader Ginsburg, Stephen Breyer, Sonia Sotomayor and Elena Kagan.

Civil rights and privacy advocates argued current rules open the doors to state abuse of a citizen's everyday activities in public and private spaces. An estimated 300,000 communications towers across the U.S. allow pinpoint accuracy as to where cellphones and those using them have been.

But the U.S. Justice Department, supported by a number of states, said if consumers knowingly give their data to third parties -- including cellphone providers -- their privacy rights are diminished. That would permit police to request the transmission data without a warrant.

The current appeal was brought by Timothy Carpenter, who was arrested for being part of a store robbery gang in Michigan and Ohio. He and a co-conspirator were convicted in part after police obtained archived cellphone records showing him near the scene of the crimes. Nearly 13,000 so-called "location points" from six months of Carpenter's movements were obtained without warrant.

His 116-year prison term was upheld by a federal appeals court. He wanted the digital evidence dismissed, and his conviction overturned.

In dissent, Justice Anthony Kennedy warned “the court’s new and uncharted course will inhibit law enforcement and ‘keep defendants and judges guessing for years to come.’”

“This case should be resolved by interpreting accepted property principles as the baseline for reasonable expectations of privacy,” he added. “Here the government did not search anything over which Carpenter could assert ownership or control. Instead, it issued a court-authorized subpoena to a third party to disclose information it alone owned and controlled. That should suffice to resolve this case.”

Justices Clarence Thomas, Samuel Alito, and Neil Gorsuch also dissented.

The government argued that under a 1986 congressional law known as the Stored Communications Act, it does not need "probable cause" to obtain archived customer records kept by the phone companies for business purposes.

Separately, police surveillance tracking of real-time movements -- or wiretapping the actual conversations of a criminal suspect -- still typically requires a judge's authorization.

The high court has been grappling with the so-called "third party" doctrine since 1976, when it ruled bank records obtained without a warrant could be used to prosecute a Georgia moonshiner. The justices extended it three years later to include phone numbers used by a robbery suspect, though not the actual conversations themselves.

In 2012, the Supreme Court unanimously said police could not attach a GPS device on the car of a suspected drug dealer to track his movements. Two years later, the justices separately and unanimously ruled police need a warrant to search a cellphone that is seized during an arrest.

But unlike those cases, in the Carpenter appeal there was no "physical intrusion" of the device, raising questions whether one's privacy was in fact being violated.