For Ibrahim Muhammed, Feb. 9, 2012, began with his arrest over a $5 bag of marijuana in a West Philadelphia drug raid.

It ended with a confession to a triple killing.

Nearly five years after Muhammed and his codefendant, Nalik Scott, both 35, were charged with murder in the deaths of three bodega workers, the detectives who worked the case and took that confession testified about the police work that they say led them to Muhammed.

Muhammed and Scott's attorneys have said the confession was false, elicited from a schizophrenic man off his medications and prompted only by a detective's hunch.

Muhammed's arrest came five months into the investigation of the deaths of Porfirio Nunez, 50; his wife, Juana, 44; and his sister Lina Sanchez, 48. They were killed in a robbery at their family bodega, Lorena's Grocery, in September 2011. The Nunezes' daughters, Jessica, then 19, and Laura, then 17, testified this week.

Jessica Nunez said Scott held them at gunpoint by the cash register and shot their father when he tried to help them. Then, in the back of the store, she said, Muhammed shot and killed their mother and aunt, and shot their father just before the men fled the store.

Muhammed was first arrested in an unrelated case, after he sold an informant about $30 worth of marijuana in a buy set up by narcotics officers, police said.

When officers subsequently raided Muhammed's house on Reedland Street in West Philadelphia, they found about $5 worth of marijuana, a narcotics officer testified. But as a police squad searched the house, the officer said, Muhammed told the officers he had information on other crimes.

His offer to talk was enough, the officer said, to send him to the Southwest Detective Division that evening, where Detective Joe Murray met him in an interrogation room.

Murray investigates robbery patterns in West Philadelphia, and had been studying video of a bodega robbery at 62nd and Reedland Streets, a half-block from Muhammed's house.

By then, investigators working the Nunez slayings believed they were connected to two similar bodega robberies, including the one on 62nd and Reedland.

"I had watched the video [of the robbery] a lot," Murray testified. "And when I went in, opened the door, and saw Muhammed, I got goose bumps."

He said he had recognized Muhammed by his nose, which he said matched that of an armed man caught on video in the 62nd and Reedland robbery.

Muhammed and Scott's defense attorneys have criticized that identification as based on nothing but Murray's repeated viewing of the video. "Murray decided [Muhammed] was the man in the video," attorney Larry Krasner said in his opening argument this week.

In the interview room, Murray said, Muhammed told him he had heard that the robbers in the 62nd and Reedland case were the Sheppard brothers, whom Murray described as local drug dealers. (The defense has alleged that one of the Sheppards, not Muhammed, could be the Nunezes' killer.)

Then, Murray said, he showed Muhammed the video of the 62nd and Reedland robbery. Muhammed pointed to the man in the video whom Murray believed to be Muhammed himself - and said the man was a Sheppard.

"Are you telling the jury that Muhammed brought up a crime he committed?" asked defense attorney Anthony Voci.

"I don't know why he told me," Murray said. "He was the one who asked to speak to detectives."

Voci questioned why Murray had not asked to search Muhammed's house for further evidence to tie him to the robberies.

"I didn't want to step on the toes of a homicide investigation," Murray said.

Murray said he thought that finding those responsible for the 62nd and Reedland robbery "would certainly help" solve the Nunez killings.

So, he said, he called homicide Detective Thomas Gaul.

At the homicide unit a few hours after Muhammed's arrest, Gaul said, he read Muhammed his rights, and told him that investigators had connected two bodega robberies to the Nunez case.

He said he told Muhammed that his fingerprint had been found at the scene of one of the robberies. That wasn't true, Gaul said in court. "I was trying to understand what his level of knowledge was," he said.

Then he brought up the 62nd and Reedland robberies. Gaul said Muhammed asked if the Lorena Grocery had video cameras like the Reedland Street bodega. It didn't, but Gaul said he danced around the question, suggesting that there were.

"Were the cameras in back by the women, or up front with the girls?" Gaul said Muhammed asked. Gaul saw his opening, he testified. He hadn't mentioned the gender of any of the victims, he said.

Gaul testified that Muhammed eventually confessed to killing the women, saying that he heard a gunshot from the front of the store and began firing without aiming, worried that someone was firing at him. He said he shot Porfirio Nunez when his gun became too hot to hold and he accidentally pulled the trigger, Gaul testified.

Gaul will continue his testimony Monday, when he is also expected to be cross-examined. Defense attorneys are building a case for mistaken identity, and challenged Muhammed's confession in opening arguments.

Krasner has said his client confessed details that were provably false, and that the statement was "primarily [the police's] own theory of the case."

215-854-2961 @aubreyjwhelan