A gunman with an assault-type rifle opened fire at the Gilroy Garlic Festival on Sunday evening, killing three and wounding 12 others, some critically, before being killed by police, Gilroy police said. A 6-year-old boy was among the dead.

Read the latest on this story here.

Police Chief Scot Smithee said the gunman — identified in news reports as 19-year-old Santino William Legan — and a companion accessed the festival through a creek and cut through a perimeter fence to avoid metal detectors. Gilroy police did not know what motivated the shooter or how the second suspect may have been involved. Authorities searched the Gilroy home of Legan’s family Monday morning, and neighbors confirmed that he lived at the home.

Witnesses reported a second suspect, and a search continued late Sunday night for that person, police said. Authorities were unsure what role the second individual played in the shooting.

The barrage of shots that rang out in the final hour of the three-day festival sent attendees diving to the ground, crawling under tables, screaming in fear and sprinting for safety.

Now Playing:

“It was quite shocking, and I’m fortunate to be alive,” said Michael Paz, 72, a hat vendor at the festival.

Paz said he was about 80 feet away from the shooter, whom he described as being in his 30s and armed with a rapid-fire assault rifle.

“He came ready to shoot because he was wearing a protective vest,” Paz said. “He was shooting left; he was shooting right without any particular aim.”

Paz said everyone immediately dropped to the ground as law officers converged on the gunman and opened fire.

At a street corner not far from the festival, officers were standing with drawn weapons. Officers were telling pedestrians to stay away from the area at Filbro Drive and Princevalle Street. It was unclear whether the activity there was related to the search for the gunman.

“Go that way! Get outta here!” officers screamed at passing pedestrians.

A chaotic video posted on Twitter shortly after 6 p.m. showed dozens of visitors running on the festival grounds. Panicked voices could be heard in the background.

“What’s going on? ... Oh, they’re shooting,” the unidentified voices said.

Another video posted to social media showed a bloodied shooting victim lying in the back of a white pickup truck, bleeding from his arm and waist.

The first 911 calls came in at 5:41 p.m. with witnesses telling police the shooter was a white male in his 20s wearing a camouflage uniform and hat with a long rifle with removable clips.

Shortly thereafter, a police officer told dispatch that he saw a Ford pickup driving off, likely to a hospital, while someone gave CPR to a victim in the bed of the truck.

At about 5:53 p.m., dispatch logs show, there was the first report of a possible shooter down in the northeast section of park.

Santa Clara Valley Medical Center was treating 11 gunshot victims and seven others wounded in the panic, said hospital spokeswoman Joy Alexiou. Eight non-gunshot wound victims were treated at St. Louise Regional Hospital in Gilroy, including one person who broke an ankle running away from the scene.

The gunshot victims’ conditions ranged from critical to fair. Some victims were treated and released.

Alexiou said the hospital system has never handled a mass shooting in Santa Clara County, but staffers were called in to triage the situation.

“This is just a tough situation for our community,” she said. “Hopefully I’ll never see anything ever like this again.”

At Santa Clara Valley Medical Center in San Jose, at least a dozen people inside the front door could be seen crying and embracing each other.

Mark Mendoza, 16, and his family said they were heading into the emergency room to find his cousin, who had been shot in the leg at the festival. Mendoza said he was near a children’s play area when a man near him opened fire.

The gunman wore a “sheriff-type outfit” and was armed with what appeared to be a semiautomatic rifle, the teenager said. He said he watched as the shooter pointed the gun at a food vendor area and began firing.

“A couple bullets hit the ground, I just ran,” Mendoza said. “I looked back, and a couple shots went by me.”

One of the bullets struck his cousin, whom he did not identify, in the leg. The family split up, some scrambling into a wooded area and through a fence. A bystander helped some of the children climb through. Mendoza’s cousin was able to run away.

Herman Solis of Hollister (San Benito County), who was attending the festival with his girlfriend, said he dropped to the ground when he heard gunfire.

“You could hear the bullets whizzing by,” he said. “It was unreal. We ran and ducked for cover. It was chaos. At first I thought it was fireworks. Then I realized it wasn’t.”

Solis and his girlfriend ran from the festival, took shelter in a nearby convenience store, and watched ambulances and police cars whiz past, heading for the festival grounds.

Another festivalgoer, Felton Amos, 60, of Rio Vista had just finished eating dinner at a food tent with his family when he heard what he thought were firecrackers. He said the shooting lasted for about a minute.

“Everybody just ran, panicked,” he said. “It sounded like more than one gun, like they were having a shootout.”

Amos pushed his family to the ground as shots rang out nearby. Then he noticed that a woman was standing nearby, frozen in fear.

“I got up and snatched her back down,” Amos said. “My mind was saying, ‘I’m going to get hit,’ but it didn’t matter.”

Marybelle Arebalo, 23, had just finished a meal of garlic ice cream, bread and fries when the crowd of panicked festivalgoers began surging past. She said she did not hear the gunfire but saw the frightened festivalgoers heading for a rocky path leading away from the festival grounds.

Arebalo said she scooped up her 1-year-old niece, plopped her in the stroller and began running with everyone else.

“I didn’t believe it actually happened,” Arebalo said. “I was in shock. It’s so sad that we couldn’t even enjoy that day. We had to think about an escape plan and safety, and people dying. I came home and started crying. I can’t put my head around it.”

Elena Diaz was waiting for her husband to pick her up from an emergency staging area at Gavilan College. She had to flee with the rest of the festivalgoers when the shooting started. She was working her booth, selling toe rings by the music stage when she heard two pops, “like fireworks” and then a rapid succession of gunfire.

She and her customers huddled behind a table, for how long she wasn’t sure.

“It was so scary,” she said. “It was like a scary movie.”

Gilroy police asked anyone with any information about the shootings to call 408-846-0583. It also is a family-reunification line.

Another festivalgoer, Briana Wilson, 20, said she had been volunteering in an olive oil booth when shots rang out. A man pushed her to the ground and, she said, told her to “hide or run.”

Wilson said she heard about half a dozen shots that sounded to her like corn popping in a microwave oven. She ran. People running alongside her were calling out for their loved ones, she said.

After running for what seemed like 2 miles, she and her friends found a man watering his lawn. He let them take refuge inside his house.

Candice Marquez, 51, a honey vendor at the festival, said she was just 10 feet from the shooter and saw him replace a clip of ammunition.

“He was super quiet, he was reloading, and we ran,” she said.

Brian Bowe, executive director of the festival, told dozens of reporters gathered in the parking lot of Gavilan College that for four decades the festival has been an “annual family reunion” for the Gilroy community.

“It is such a sad, horribly upsetting circumstance,” Bowe said. “It’s one of the most tragic and sad things that I’ve ever had to see.”

State elected officials condemned the violence even as police were still seeking the shooter.

“This is nothing short of horrific,” tweeted Gov. Gavin Newsom.

Santa Clara County sheriff’s deputies assisted Gilroy police officers at the scene, a sheriff’s department spokeswoman said. First responders from San Jose and Salinas also assisted, as did units from the San Francisco office of the Bureau of Alcohol, Tobacco, Firearms and Explosives.

The violence in Gilroy is among the few hundred mass shootings in the U.S. each year, generally defined as killing or injuring four or more people. Last week, a shooter in the San Fernando Valley killed four people, two of whom were the gunman’s family members.

California’s deadliest shooting in recent years was November’s bloodshed in Thousand Oaks (Ventura County), where a shooter killed 12 at a crowded bar. The nation’s worst shooting remains the 2017 rampage in Las Vegas, where a gunman killed 58 and injured more than 500 at a country music concert.

While the number of mass shootings hasn’t necessarily risen in recent decades, the death tolls have generally grown. While legislators have tightened gun laws in some states, including California, other states have resisted changes — and few reforms have come on the national level.

Notably, federal law still allows private-party sales without background checks, known as the gun-show loophole.

“Our country has a gun violence epidemic that we cannot tolerate,” tweeted Sen. Kamala Harris.

Chronicle staff writers Lizzie Johnson, Kurtis Alexander, Ashley McBride and Matthias Gafni contributed to this report.