After being held for trial Tuesday on murder charges in a July 2018 fatal shooting in Hunting Park, Rashad Heard hurled some unkind words toward Municipal Court Judge Wendy Pew.

“B—!” he yelled at the judge, who told him to sit down. “I’m not going to sit down,” he said, repeating the expletive as two sheriff’s deputies pushed him into his chair at the defense table.

As Pew told Heard that she was finding him in contempt, Heard, a tall, bearded man in a black skullcap, yelled, “Who gives a [expletive]?”

Earlier, Pew was telling Heard, 29, of Strawberry Mansion, that he was being held for trial on murder, weapons, and related offenses in the death of Khalil Madison, 34, when Heard again began cursing at her.

Madison’s fatal shooting took place about six months after Heard had been released from a city jail after the District Attorney’s Office withdrew gun-possession charges against him on Jan. 12, 2018, in a separate matter stemming from July 2017.

Court records indicate the charges were dropped based on “prosecutorial discretion."

Ben Waxman, spokesperson for District Attorney Larry Krasner, who took office last year, said by email Tuesday that charges were dropped in the 2017 gun-possession case because additional investigation in January 2018 "revealed newly available video and physical evidence; after review, one of our prosecutors determined that the original allegations were inconsistent with the available evidence.”

At Heard’s preliminary hearing Tuesday in the murder case, Assistant District Attorney Steven Patton called two witnesses to the stand.

Donald Green testified that about 11:10 p.m. on July 27, 2018, he was driving a Nissan Rogue SUV with a man nicknamed “Weezy” in the front passenger seat and Madison, nicknamed “Gorilla,” and Heard, who introduced himself as “M,” in the backseat.

Green said Heard was supposed to give them Suboxone, a drug used to help with opioid or heroin addiction.

But, Green testified, Heard and Madison began arguing about the money, and Heard pulled out a gun and put it to Madison’s chest.

The two men “started tussling over the gun, and there was a pop" as Heard shot Madison, Green testified.

“Me and Weezy jumped out of the car,” said Green, who had stopped the SUV on the 600 block of Rising Sun Avenue.

Heard and Madison also got out of the car, and Heard shot Madison two more times, testified Green, who said he then jumped back into the SUV and drove off alone.

Police took Madison to Temple University Hospital, where he was pronounced dead at 11:33 p.m.

Heard was a fugitive until police arrested him Dec. 23.

Police Officer Kyle Bobiy testified that about 10:15 a.m. that day, he responded to a radio call of a person with a gun at 19th Street and Erie Avenue in Tioga. Bobiy testified that Heard was at the corner and that after getting out of his police car, he ran after Heard, who threw something under a car.

Bobiy said he caught up to Heard and arrested him, then recovered a Glock from under the car.

After Pew held Heard for trial on the murder case and Heard yelled at the judge, he was taken out of the courtroom, then brought back two hours later so the judge could address him on his outbursts.

This time, Heard was calm as Pew sentenced him to five months and 29 days behind bars for contempt.

“I apologize,” Heard said.