Video released by Arizona police shows how a four-year-old girl narrowly escaped being shot when gunfire shattered the windows of a barber shop she was playing in.

The girl was sitting down in a chair by the shop's window in Chandler when two bullets were shot at head level, narrowly missing her and sending her running in a panic.

The girl was struck by shattered glass and was taken to hospital, but authorities said her life is not in danger.

She reportedly suffered small cuts on her face.

Police said the barber shop was not the intended target of the shooting. Rather, the alleged gunman, David Hart, was aiming at a tattoo parlour next door.

The 23-year-old Hart had been told to leave by the owner of Damaged Ink Tattoo and asked to come back when he was not intoxicated, according to local newspaper The Arizona Republic.

After leaving the shop, Hart went to his car, got a gun from the trunk, drove by and started shooting, police said.

He was subsequently arrested at a nearby home. Police also arrested another man, 21-year-old Rafael Santos, who allegedly was in the car with Hart at the time of the shooting.

Residents of the area were shocked.

"It's shocking. It's ridiculous that stuff goes on," said neighbour Alan Bronson.

"We have a seven-month old we're raising. You see stuff like that, it makes you angry."