An off-duty NYPD cop, whose cousin swiped his gun and shot a would-be robber, was stripped of his gun and badge on Wednesday, a police source said.

The cop, Khaleef Allicott, and his cousin, Travis Dominique, were coming out of the Bleachers Sports Bar & Grill with a few women early Tuesday when Agusta Clay and another man ambushed them, the source said.

But when Clay tried to rob the group, Dominique grabbed Allicot’s gun and fired, a witness told investigators. Clay was hit in the right leg, and stumbled over to New York Methodist Hospital at about 1 a.m. in stable condition.

Allicot, an officer for five years, is stationed in the 71st Precinct in Crown Heights, the source said.

Dominique was initially arrested but that arrest was later sealed. It wasn’t immediately clear what the charges were or why it was sealed.

Clay was charged with attempted robbery and was awaiting arraignment. He remained in the hospital on Wednesday.