Police mistakenly raided a San Francisco couple’s apartment in search of stolen iPhones, ransacking the unit while officers took a young man into custody and shouting at his shocked wife, who was wearing only a towel, according to a federal lawsuit filed Friday.

But as the team of officers ripped through the couple’s personal belongings that day in 2017, they slowly began to realize they had goofed, attorney Josh Brownstein wrote in the lawsuit.

It turns out Rick Garcia had legally purchased his iPhone two weeks earlier from the Apple store at Stonestown Galleria. And, at 5 feet 9 and 120 pounds, he clearly wasn’t one of the three “husky” burglars police were looking for who had targeted that store, his attorney said.

Garcia and his wife, Shannon Knuth, are now suing the city and its Police Department after suffering “physical and emotional injuries” in the episode, Brownstein wrote.

Officials with the San Francisco Police Department said they could not comment on the case because of pending litigation. The city attorney’s office said it is reviewing the lawsuit, but “it would be premature for us to comment substantively at this time.”

The episode began after a team of burglars stole 300 iPhones from the Apple store at Stonestown Galleria on Nov. 1, 2017, according to the lawsuit.

The investigation was assigned to the Police Department’s newly formed General Crimes Unit, a team of 35 officers dedicated to crimes such as burglaries, robberies and bicycle thefts. The case, Brownstein said, was the first one assigned to the new unit.

More than two weeks later, on Nov. 19, Garcia bought his new iPhone X from the same Apple store along with a leather case, totaling $1,498.84, his attorney said.

Then on the early morning of Dec. 4, 2017, Garcia was “abruptly awakened by a shouting and banging emanating from his exterior hallway,” Brownstein said, adding that police were shouting from the hall, “San Francisco Police Department” and “search warrant.”

While his wife was in the shower, Garcia approached the door, looked through the eyehole and saw police with a battering ram preparing to bust in, his attorney wrote.

When Garcia opened the door, Brownstein said, police rushed in, pulled Garcia into the hallway, handcuffed him and took him to Taraval Station for questioning.

Back at the apartment, officers shouted at Knuth, who was in a towel and was “confused and extremely frightened,” Brownstein said. “She insisted that something was wrong — that they must be mistaken.”

Police began searching the home and handed Knuth “a bra, thong underwear, yoga pants and a sweatshirt” and told her to get dressed in the bathroom, her attorney said.

Once Knuth was dressed, and police told her they were looking for a iPhone X, she showed them the receipt, proving Garcia legally owned the phone, Brownstein said.

Realizing their blunder, police brought Garcia back home to the ransacked apartment, the attorneys said.

“After the SFPD left with their battering ram and pry bar, Mr. Garcia and Ms. Knuth sat and witnessed the disarray that their home was put in by the SFPD,” Brownstein wrote. “As they commiserated, they overheard several SFPD officers outside their window laughing and joking about a ‘pending lawsuit.’”

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: esernoffsky@sfchronicle.com Twitter: @EvanSernoffsky