An upstate New York cop running away from a rabid fox accidentally shot himself in the chest — but was saved by his bulletproof vest, police said.

Village of Ellenville officer Harold Nunuvero, 24, was being pursued by the infected beast in the village Tuesday, when he tried to climb a chain link fence to escape.

But his foot got caught in the fence and he flipped over onto his back.

Nunuvero’s gun went off just as he landed — though luckily, he was wearing his flak jacket.

Another officer was able to shoot and kill the fox while Nunuvero was on the ground.

Village police Chief Philip Mattracion said the officer’s bulletproof vest “without doubt, without question” saved his life.

Nunuvero, an officer for four years, was treated at a local hospital and released. He’ll be back at work Friday.

With Post wires