Allegheny County homicide detectives wrote in a criminal complaint last month that Mr. Porter — the uncle of Pittsburgh rapper Wiz Khalifa — thought he was meeting people near the restaurant to sell heroin when at least two men attempted to rob him and he was shot.

Detective Daniel Mayer testified today that Mr. Wolford told investigators that after Mr. Porter placed the heroin on the center console inside the car where the deal was taking place, he pointed the gun at Mr. Porter and said, “Let me get this one for free.”

“He indicated that [Mr. Porter] tried to push the gun away, and it went off,” the detective said.

Leevan Jefferson, 25, testified Friday that he was facilitating a drug deal that day between two friends: Mr. Porter, who he said was looking for a buyer, and Mr. Young, the brother of Mr. Jefferson’s child’s mother.

The deal was taking place in Mr. Jefferson’s vehicle with Mr. Porter, Mr. Wolford and Mr. Young. Mr. Sanders was not in the car.

Mr. Jefferson testified that Mr. Young, who he said also pulled out a gun inside the car, seemed “in shock” after the shooting. He also testified that the gun sounded like it went off from the seat behind him — where Mr. Wolford was sitting — but said he couldn’t be sure who fired.

Attorney Ralph Karsh maintained that Mr. Sanders, who prosecutors say drove the car the three suspects rode in, was not implicated by the evidence presented Friday and asked Judge Olsaz to dismiss all charges against him.

The judge declined, saying that prosecutors, “however slight,” had met their burden of proof at the preliminary hearing level.