A man was grazed by a bullet inside an East Harlem apartment building Wednesday morning following an argument with the nearly naked gunman — who only had his underwear on, police said.

The 20-year-old and the shooter — who was wearing only his skivvies, according to a 911 caller — were fighting inside AK Houses on East 128th Street near Lexington Avenue around 7:35 a.m. when the nearly naked man shot him once, cops said.

The victim was taken to Harlem Hospital with a non-life-threatening graze wound to his jaw, according to authorities.

The gunman fled into an adjacent building, but was nabbed by cops shortly thereafter, police said.

Charges against him were pending.