In a unanimous decision, the Arizona Supreme Court ruled Monday that the police overstepped when an officer warrantlessly searched the phone belonging to a man who had been an overnight guest at a female neighbor’s apartment.

According to the 10-page opinion, Tucson police were called when the woman, referred to as “D.C.,” was found unresponsive in bed by her daughter. D.C. had been dating the man who lived next door, Robin Peoples, for a few months, and she had invited him to spend the night. The next morning, while Peoples was in the bathroom, D.C.’s daughter, who lived in the same apartment complex as her mother, arrived. When her mother did not respond, the unnamed daughter called 911.

Peoples ran from the apartment to direct paramedics, but inadvertently left his phone behind. Paramedics arrived and began tending to D.C., but soon after pronounced her dead. Peoples “sought solace,” according to the opinion, at a neighbor’s apartment.

The opinion continued:

Tucson Police Officer Travis Mott came to D.C.’s apartment after she was pronounced dead. He looked for information that might identify D.C.’s doctor, hoping the doctor could shed light on D.C.’s recent health and sign the death certificate. He found a “smart” cell phone in the bathroom. Assuming the phone belonged to D.C., the officer turned it on and opened it with a finger swipe to search her contacts (it was not passcode protected). A paused video-image of D.C. on her back in bed, mostly naked, appeared on the screen. The officer pressed “play” and watched part of a video of Peoples having sex with a seemingly unresponsive D.C. Before he watched the video, Officer Mott had been told that Peoples spent the night at the apartment.

Not long after, Peoples returned to get his phone back.

According to Officer Mott, after viewing the video, he detained Peoples in his apartment, read him his Miranda rights, and questioned him about the video. Peoples confirmed that he had sex with D.C. during the early morning hours and filmed it with his phone. Peoples also told Officer Mott that D.C. “probably was [dead]” when they had sex, although he “thought she was breathing” and had heard “her snoring earlier.” Peoples later watched the video with other officers and answered their questions.

Largely based on the video and his own responses to officers’ questions, Peoples then was charged with necrophilia and two counts of sexual assault.

Eventually, his attorney moved to challenge the evidence of the video found on his phone, as it was obtained via a warrantless search. A lower court found in his favor. When prosecutors appealed to a higher court, it ruled in the government’s favor.

Prosecutors had argued that because Mott believed the phone belonged to D.C., who was dead, that there was no privacy interest at issue. They also argued that because the phone was not passcode-protected, there was no reasonable expectation of privacy. Peoples then appealed to the state’s highest court.

But in the Monday opinion, writing for the court, Justice Ann Scott Timmer didn’t buy the government’s claims.

“Cell phones are intrinsically private, and the failure to password protect access to them is not an invitation for others to snoop,” she wrote.

She also wrote that state appellate court’s reasoning conflicted with the landmark 2014 United States Supreme Court decision, Riley v. California. That decision found, also unanimously, that police could not search the phone of someone who is arrested without a warrant.

“The court of appeals’ limitation is at odds with the Supreme Court’s reasoning that cell phones contain ‘the privacies of life’ and are therefore worthy of Fourth Amendment protection,” Justice Timmer concluded. “That privacy is no less worthy of protection when a cell phone is outside a person’s immediate control.”