Police were searching on Monday for a suspected accomplice of the gunman who killed three people, including a 6-year-old boy, in a mass shooting at a food festival in California.

The gunman was shot dead by police officers within minutes of opening fire early on Sunday evening at the three-day Gilroy Garlic Festival, about 30 miles (48 km) southeast of the city of San Jose.

Among those killed was a 6-year-old boy, according to news reports. Fifteen people were injured, but it was unclear how many were shot or otherwise hurt in the crush of bystanders trying to flee, according to police. One person was in critical condition, a hospital spokeswoman said.

A second suspect "was involved in some way, we just don't know in what way," Gilroy Police Chief Scot Smithee said late on Sunday, without giving further details.

"We have no idea of a motive," he said. Police recovered a rifle at the scene, Smithee said.

The gunman, who has not been publicly identified, cut through a fence to evade metal detectors and other security at the festival's entrance, police said.

Footage uploaded to social media showed festival attendees scattering in fear and confusion as loud popping sounds could be heard in the background.

"What's going on?" a woman can be heard asking on one video. "Who'd shoot up a garlic festival?"