A 23-year-old man who was shot on a Mira Mesa hiking trail Wednesday night responded by biting off the finger tip of the alleged gunman in self-defense, San Diego police said.

Officers received a report of a shooting and fight occurring between two men on a trail near Maya Linda and Black Mountain roads around 9:50 p.m., police Officer Jose Perales said.

Investigators said the 47-year-old gunman fired a handgun twice at the 23-year-old man, causing a “grazing gunshot” wound to his lower torso, Perales said.

The victim fought back and bit the top part of the suspect’s middle finger off during a struggle after the shooting, investigators said.

Both men were taken to the hospital.

The gunman was arrested on suspicion of assault with a deadly weapon, Perales said. A firearm was recovered at the scene.

It was not immediately clear what circumstances led up to the shooting or what the relationship, if any, was between the two men.