The two cases arose after arrests in San Diego and Boston.
In San Diego, police found indications of gang membership when they looked through defendant David Leon Riley's Samsung smartphone. Prosecutors used video and photographs found on the smartphone to persuade a jury to convict Riley of attempted murder and other charges. California courts rejected Riley's efforts to throw out the evidence and upheld the convictions.
The court ordered the California Supreme Court to take a new look at Riley's case.
In Boston, a federal appeals court ruled that police must have a warrant before searching arrestees' cellphones.
Police arrested Brima Wurie on suspicion of selling crack cocaine, checked the call log on his flip phone and used that information to determine where he lived. When they searched Wurie's home and had a warrant, they found crack, marijuana, a gun and ammunition. The evidence was enough to produce a conviction and a prison term of more than 20 years.
The appeals court ruled for Wurie, but left in place a drug conviction for selling cocaine near a school that did not depend on the tainted evidence. That conviction also carried a 20-year sentence. The administration appealed the court ruling because it wanted to preserve the option of warrantless searches following arrest.
The justices upheld that ruling.
The decision will protect cellphones from warrantless searches going forward, but it may not be of much help to defendants in pending cases, or those whose convictions are final, said Gerry Morris of Austin, Texas, a vice president of the National Association of Criminal Defense Lawyers.
Morris said that courts could allow evidence to be used from police searches of cellphones that were done in "good faith" and relied on the law as it stood when the searches were conducted.
What about other countries?
Canada's Supreme Court ruled last year, much as the U.S. justices did, that officers need a specific warrant to search a computer or a cellphone because the devices "give police access to an almost unlimited universe of information."
In Britain, however, warrantless searches of cellphones and other electronic devices are routine; London police stations are even equipped with special devices to suck data from the phones of arrestees as they're booked.
Wednesday's cases are Riley v. California, 13-132, and U.S. v. Wurie, 13-212.
Associated Press writers Nancy Benac in Washington and Raphael Satter in London contributed to this report.