The gunman was shot dead by police shortly after he began firing, although police are investigating reports that a second suspect may still be at large.
The Gilroy Garlic Festival was about to end for the weekend on Sunday evening, when shots were fired at the site.
Eyewitnesses told NBC there was a white man in his early to mid-30s firing a rifle.
According to US Tracking Website Gun Violence archive, it was the 246th mass shooting in the US this year.
Gilroy Chief of Police Scot Smithee told reporters the suspect entered the festival after cutting through a perimeter fence.
He said witnesses reported that a second suspect might have been involved, possibly in a support role.
Chief Smithee added officers were already at the site and responded to the shooting in less than a minute.