Police shot a suspect who allegedly got out of a minivan brandishing a gun during a traffic stop Wednesday night in Harlem, the NYPD said.

Gunfire erupted after NYPD, state and DEA investigators stopped the vehicle at 125th Street at 12th Avenue near the West Side Highway, police said.

One of the car's passengers, a 30-year-old man, got out of the van armed with a .40-caliber handgun, police said. That's when officers opened fire, grazing the man in the arm. It's not clear how many shots were fired.

The suspect was treated and released from the hospital. Charges against the man are pending, police said.

Another suspect was hurt when the van's glass shattered during the shooting, the NYPD said.