Another cop nearby saw the attack and chased the perpetrator, managing to arrest him and get the gun. The second cop didn't realize it was a fellow cop had been injured. The police do not believe the gun was fired.
The beaten cop is in serious but stable condition at Elmhurst Hospital. The police said that 21 year old Danny Fernandez was the attacker; it's unclear what caused the incident, which occurred at 102nd Street and 39th Avenue. The NY Times reports that the attacked cop had been assigned to an "impact post" - "foot patrol in a high-crime area."