ASBURY PARK, N.J. (AP) — A stray bullet went through the back of a house and grazed an 8-year-old girl watching television after a police officer and suspect exchanged gunfire in a New Jersey shore town, prosecutors said Thursday.

Dante Allen, a 20-year-old man who was being chased by an Asbury Park officer Wednesday night and fired toward the patrolman, was charged with attempted murder and weapons charges, Acting Monmouth County Prosecutor Christopher Gramiccioni said.

Investigators weren't sure which of the shots entered the house and hit the girl, who was treated and released from a hospital Wednesday night.

Allen's injuries were not life-threatening and the officer was not hit. It wasn't immediately clear if he had an attorney to comment on the charges.

A handgun was found at the scene.

"I heard the mom crying," Kyraun Wilson, who lives across the street, told the Asbury Park Press. "She said, 'My baby got shot.'"

Derek Reevey lives next door and said a bullet hit the exterior of his house, but was stopped by a beam near where his wife was sitting watching television.

"This is too close to home," he told the newspaper. "You can't be safe in your own home."

Investigators said the officer stopped Allen as part of an "investigatory stop" and felt the gun. He then took off running and the officer gave chase before they fired at each other, investigators said.

Gramiccioni defended the officer's decision to fire.

"An officer has an obligation to extinguish a threat like that," he said.