Two men in Queens were allegedly robbing another man at gunpoint — when one crook fatally shot the other in the head while pistol-whipping the mugging victim, police said Wednesday.

The pair approached a 38-year-old man outside a building on 160th Street near Tuskegee Airmen Way in Jamaica around 1:15 p.m. Tuesday and told him to hand over his $225 necklace, police said.

One of the suspects pulled out a gun and told the man, “You want to live?,” according to police.

He then snatched the necklace and began pistol-whipping the victim.

During the struggle, the robber’s gun fired and hit his fellow thief, 24-year-old Tyrell Simms, in the head, officials said.

Simms was rushed to Jamaica Hospital, where he was pronounced dead.

The armed man, 46, was in police custody Wednesday and is expected to be charged in both the mugging and the shooting, sources said.