The detective who shot and wounded NYPD Officer Jonathan Diller’s accused killer said he saw the gun in the ex-con’s hand moments before he fired the fatal shot during a day of chilling courtroom testimony in Queens Thursday.

Det. Veckash Khedna told jurors in Queens Supreme Court that he had a clearer view than the body-worn camera on his chest when Guy Rivera pulled out a gun while sitting in the passenger seat of a Kia sedan that Diller and his team had stopped on March 25, 2024.

NYPD Det. Veckash Khedna is pictured in an undated photo. Khedna was working with NYPD Officer Jonathan Diller the night Diller was fatally shot. (NYPD)NYPD Det. Veckash Khedna is pictured in an undated photo. Khedna was working with NYPD Officer Jonathan Diller the night Diller was fatally shot. (NYPD)

“He had the gun in his hand and he’s looking exactly at Diller,” Khedna said at Rivera’s trial.

“At that moment I heard a bang, I heard a gunshot It came from the defendant, he fired a weapon, he fired a gun. And I heard DIller start screaming. He started screaming, He’s in a lot of pain.”

Rivera, 35, faces murder, attempted murder and weapon possession charges nearly two years after prosecutors say he fatally shot Diller in the stomach during a car stop on Mott Ave. in Far Rockaway.

Khedna and another detective, Derval White, were talking to a man they had stopped on the sidewalk when Diller drew their attention to a car he and two other members of their team, Sgt. Sasha Rosen and Det. Dario Fernandez, had surrounded.

Police secure a vehicle in front of 1919 Mott Ave. in Far Rockaway, Queens, after NYPD Officer Jonathan Diller was fatally shot while making a car stop on Monday, March 25, 2024. (Sam Costanza for New York Daily News)Police secure a vehicle in front of 1919 Mott Ave. in Far Rockaway, Queens, after NYPD Officer Jonathan Diller was fatally shot while making a car stop on Monday, March 25, 2024. (Sam Costanza for New York Daily News)

Rivera’s defense team has argued that his gun went off accidentally after Rosen reached into the car and grabbed it, trying to leverage footage from body cameras and surveillance cameras that don’t offer a clear view of the gun or the sergeant’s hands inside the car.

But Khedna testified that his line of sight was higher than his body camera’s view, which meant he had a clear view inside the car as the episode unfolded.

“He had full control of the gun,” Khedna said of Rivera.

The detective also testified he saw Rivera push his way out of the vehicle and pointed his gun directly at Rosen’s chest.

Khedna said he fired two shots, just moments apart, as Diller fell to his knees while Rosen and Rivera struggled.

Police secure the scene on Mott Ave. in Far Rockaway, Queens after NYPD Officer Jonathan Diller was fatally shot while making a car stop.

Sam Costanza for New York Daily News

Police secure the scene on Mott Ave. in Far Rockaway, Queens after NYPD Officer Jonathan Diller was fatally shot while making a car stop on Monday, March 25, 2024. (Sam Costanza for New York Daily News)

He then moved to cuff Rivera, who dropped to the ground, and he heard Diller yell, “I’m shot! I’m shot!” he said

“And he was on his knees, and then he falls down, and he never came back up,” Khedna said, crying.

In a tense criss-examination, Rivera’s defense attorney, Jamal Johnson, pressed Khedna on what he saw and what was visible on camera.

“You shot (Rivera) in the back, is that correct?” Johnson asked at one point, getting the reply, “I did not shoot him in the back.”

Johnson also used Khedna’s body camera footage to push back on testimony from previous witnesses in the case that Rivera was smiling as he lay on the ground wounded, suggesting that his client had actually been grimacing in pain.

Guy Rivera, charged in the fatal shooting of NYPD Officer Jonathan Diller, listens to opening statements as his trial begins at Queens Criminal Court on Tuesday, March 10, 2026. (Dave Sanders/Pool/The New York Times)Guy Rivera, charged in the fatal shooting of NYPD Officer Jonathan Diller, listens to opening statements as his trial begins at Queens Criminal Court on Tuesday, March 10, 2026. (Dave Sanders/Pool/The New York Times)

He went frame-by-frame, asking Khedna, “Is Mr. Rivera smiling here?” and “You believe he is smiling, and not grimacing?”

“He was smiling multiple times,” Khedna said after seeing one frame.

“He was smirking,” he said, twice, after two more. “I’ve answered this question so many times.”

That line of questioning drew a rebuke from Judge Michael Aloise, who paced back and forth behind the bench, repeatedly sustaining the prosecution’s objections.

Aloise also shut down a line of questioning where Johnson asked the detective if he told the shooter to “stand the f— up.”

After the jury left for lunch, Johnson argued the “defense counsel has been limited in a very extraordinary way” in its ability to impeach the credibility of the police witnesses or question Rosen on his “prior bad acts.”

Aloise challenged that, saying, “With respect to the incident itself, you’ve not been limited at all.”

The trial continues Friday.