A 32-year-old man was shot after he apparently tried to rob an off-duty cop and his cousin in Park Slope early Tuesday, a police source said.

The suspect, identified by a source as Agusta Clay, and another man walked up to the cop, Khaleef Allicott, near the corner of Prospect Place and Sixth Avenue and put a gun to his head, the source said a witness told investigators. That’s when his cousin, Travis Dominique, apparently grabbed Allicott’s gun and fired.

Allicott and Dominique had just left the nearby Bleachers Sports Bar & Grill with a few girls, the source said.

Clay then stumbled into New York Methodist Hospital at about 1 a.m. with a gunshot wound to his right leg, cops said. He was in stable condition, police said.

The shooting was under investigation by the NYPD’s Force Investigation Division.