The cousin of an off-duty police officer used the cop’s gun to shoot a thief who was trying to rob them outside a Brooklyn bar early Tuesday, police sources said.

Officer Khaleef Allicott was walking to his car with his girlfriend and cousin Travis Dominique, 25, at 12:30 a.m. when two men – one armed with a gun – accosted them near the corner of Prospect Place and 6th Avenue, sources said.

Allicott, who works in the 71st Precinct in Crown Heights, allegedly shoved the thief away when he tried to snatch a gold chain from around his neck, sources said.

During the struggle, Dominique retrieved the gun from his cousin’s car and then shot one of the crooks in the leg, police said.