Washington (CNN) The Supreme Court on Friday said the government generally needs a warrant if it wants to track an individual's location through cell phone records over an extended period of time.

The ruling is a major victory for advocates of increased privacy rights who argued more protections were needed when it comes to the government obtaining information from a third party such as a cell phone company.

The 5-4 opinion in Carpenter v. United States, was written by conservative Chief Justice John Roberts siding with the four most liberal justices.

It is a loss for the Justice Department, which had argued that an individual has diminished privacy rights when it comes to information that has been voluntarily shared with someone else.

The opinion, which was limited to cell-site location data, continues a recent trend at the court to boost privacy rights in the digital era and clarifies court precedent as it applies to data held by a third party.

Cell phones play a "pervasive and insistent part of daily life," Roberts wrote.

"Virtually any activity on the phone generates" the data, Roberts said, "including incoming calls, texts, or e-mails and countless other data connections that a phone automatically makes when checking for news, weather, or social media updates."

"Here the progress of science has afforded law enforcement a powerful new tool to carry out its important responsibilities," Roberts added. At the same time, he said, "this tool risks Government encroachment of the sort the Framers after consulting the lessons of history, drafted the Fourth Amendment to prevent."

He noted, however, that there would be exceptions to the need for a warrant, including pursuing suspects or protecting individuals threatened with imminent harm.

Steve Vladeck, a CNN Supreme Court analyst and professor at the University of Texas School of Law, said the ruling "could portend a revolution in how courts understand and enforce privacy rights in the digital age."

"For 40 years, the assumption has been that individuals have no expectation of privacy in any information we voluntarily share with third parties -- from phone records to bank statements to how and where we buy and sell goods," Vladeck said.

"Even though today's ruling argues that cell-site location data is unique, it's easy to see how it will open the door to countless other contexts in which privacy advocates and criminal defendants will argue for similar privacy protections - and similar warrant requirements," he added, saying to watch Roberts in the future.

"Today's decision also suggests that the chief justice, who sided with he four Democratic appointees in the 5-4 ruling, is increasingly becoming the court's swing vote on questions of digital privacy," Vladeck said.

ACLU attorney Nathan Freed Wessler called the decision "a groundbreaking victory for Americans' privacy rights in the digital age." He added, "The Supreme Court has given privacy law an update that it has badly needed for many years, finally bringing it in line with the realities of modern life."

The Supreme Court returns Monday for the final week of the term, when it is expected to rule on cases including President Donald Trump's travel ban, Texas redistricting and a California abortion notice law.

The dissent

While the majority opinion covered 23 pages, the dissents covered a total of 92.

Not only did four Republican-appointed justices, Anthony Kennedy, Clarence Thomas, Samuel Alito and Neil Gorsuch dissent, each chose to write their own opinion, some of which, were joined by others.

Kennedy wrote a dissent joined by Thomas and Alito and said that the Court's departure from precedent was "unnecessary, and incorrect."

Kennedy in his dissent said the majority's opinion "puts needed, reasonable, accepted, lawful and congressionally authorized criminal investigations at serious risk in serious cases, often when law enforcement seeks to prevent the threat of violent crimes." He also said that it places "undue restrictions" on the "lawful and necessary enforcement powers exercised not only by the Federal government, but also by law enforcement in every State and locality throughout the nation."

Kennedy also argued that "Cell-site records, however, are no different from the many other kinds of business records the Government has a lawful right to obtain by compulsory process.

"Customers ... do not own, possess, control, or use the records, and for that reason have no reasonable expectation that they cannot be disclosed pursuant to lawful compulsory process," he added.

Alito, who was joined by Thomas, in a 27-page dissent said he feared the majority opinion would do "more harm than good."

"The Court's reasoning fractures two fundamental pillars of Fourth Amendment law, and in doing so, it guarantees a blizzard of litigation while threatening many legitimate and valuable investigative practices upon which law enforcement has rightfully come to rely."

Armed robberies spurred case

The case came after a string of armed robberies at Radio Shack and T-Mobile stores in Michigan and Ohio.

A robber who confessed to the crimes gave the FBI his own cellphone number and the numbers of other participants in the robbery scheme. Pursuant to the Stored Communications Act, a law that authorizes the government to obtain cell service provider's records under certain circumstances, the FBI obtained cell-site records placing Timothy Carpenter and Timothy Sanders near each of the robberies.

Carpenter and Sanders were later charged with aiding and abetting robbery.

Lawyers for the defendants moved to suppress the cell-site evidence arguing that the "reasonable grounds" standard necessary for the information under the federal law was too low a standard of proof. Instead, they argued that the Fourth Amendment required the government to obtain a search warrant pursuant to a showing of probable cause before obtaining the data.

A federal appeals court ruled in favor of the government, holding that while the Fourth Amendment "protects the content of the modern-day letter," courts have not yet "extended those protections to the internet analogue to envelope markings, namely the metadata used to route internet communications, like sender and recipient addresses on email, or IP addresses."