A police officer fatally shot a pit bull after it attacked its owner in Harlem on Friday night, according to the NYPD.

Investigators said the 71-year-old man was walking his dog on Lenox Ave. and 145th St. around 8:17 p.m. when the dog started to maul him.

The officer was on his way back from the Bronx-Lebanon Hospital shooting when he saw the attack happening and shot the dog several times.

The pit bull died at the scene.

The owner was taken to Harlem Hospital in serious condition with several bite wounds.

Police believe he had gotten the dog just hours earlier from an owner who no longer wanted it.

Photo above courtesy Instagram user @cameronbenison