A security officer at the Naval Medical Center in San Diego fired his gun at a charging dog Monday night, but missed and shot a man in the ankle, officials said.

The shooting occurred just after 8:30 p.m. near the hospital's main gate, Navy Region Southwest spokesman Brian O’Rourke said in a statement.

NAVY LIEUTENANT, WIFE ACCUSED OF CONSPIRING TO SMUGGLE INFLATABLE BOATS TO CHINA

Officials said Eric Durand, 18, was trying to get to the San Diego Zoo, which is one street away from the medical center's access gate.

Durand pulled into the medical center driveway and drove up to the main gate without stopping for guards, officials said. A barrier was ultimately deployed to stop the vehicle.

"Durand got out of the vehicle in an agitated state, yelling at the sentry [point]," O'Rourke said.

A dog jumped out of the vehicle and charged the guards, one of whom fired a weapon.

CLICK HERE TO GET THE FOX NEWS APP

Durand was taken to a local hospital for treatment. He was also issued a citation for trespassing on federal property and barred from all Navy bases for life.

The dog was not harmed but was taken into custody by San Diego Animal Control officers.