Police in Hatfield shot and injured a knife-wielding man who was seen wandering around the backyards of two suburban homes early Friday, according to prosecutors.

The 29-year-old man, whom investigators did not identify, was undergoing surgery Friday at Grandview Hospital, according to Montgomery County District Attorney Kevin Steele, whose office will be investigating the shooting.

Hatfield Township police were called to a home on Leon Drive just after 7:30 a.m. after a resident reported seeing the man running through her yard and hiding in her next-door neighbor’s yard, according to Steele.

When the officers arrived, they found the man between two woodpiles in that backyard. When ordered to show officers his hands, he refused, Steele said.

After the man ignored their commands, the officers used a Taser on him, according to the prosecutor. The man then got up and charged the officers, who fired at him and struck him several times, Steele said. The officers later recovered a knife from the scene, he said.

It wasn’t immediately clear how many officers shot the man, or how many times he had been shot.