Three people were killed and at least 15 others injured Sunday after a shooting that sent panicked people running at an annual food festival in Northern California. Also dead is the shooter, who used a rifle and gained entry to the packed festival by cutting through a fence to avoid the tight security, including metal detectors, police said.

Some witnesses reported a second suspect, Gilroy Police Chief Scot Smithee said, but it was unclear whether that person opened fire. Police confronted the gunman within a minute of shots being fired.

Witnesses reported confusion and panic as shots rang out at the Gilroy Garlic Festival in the city of 50,000 located about 176 kilometres southeast of San Francisco.

The shooting occurred during the three-day celebration featuring food, cooking competitions and music that attracts more than 100,000 people. Sunday was the final day of this year's event.

Watch as people disperse from the festival as shots ring out:

Witnesses reported confusion and panic as shots rang out at the Gilroy Garlic Festival in Northern California. Three people were killed and at least 15 others injured. 0:28

The band Tin Man was just starting an encore when shots rang out.

Singer Jack van Breen said he saw a man wearing a green shirt and grayish handkerchief around his neck fire into the food area with what looked like an assault rifle.

Gilroy Police Chief Scot Smithee speaks at a news conference at Gavilan College. (Josie Lepe/Associated Press)

Van Breen and other members of the band dove under the stage. Van Breen says he heard someone shout: "Why are you doing this?" and the reply: "Because I'm really angry."

His band member Vlad Malinovsky from Walnut Creek, Calif., said he heard a lot of shots and then it stopped. Later, law enforcement came by and told the band members and others hiding with them to come out with their hands up.

Stanford Medical Center has two patients being treated from the shooting at the Gilroy Garlic Festival, spokesperson Julie Greicius said. She had no details on their injuries or conditions. Santa Clara Valley Medical Center received five victims, spokesperson Joy Alexiou said. She also had no information on their conditions.

People are seen leaving the Gilroy Garlic Festival following the shooting. (Nhat V. Meyer/San Jose Mercury News via AP)

Evenny Reyes of Gilroy, 13, told the Mercury News that she spent the day at the festival with her friends and relatives.

"We were just leaving and we saw a guy with a bandanna wrapped around his leg because he got shot. And there were people on the ground, crying," Reyes said. "There was a little kid hurt on the ground. People were throwing tables and cutting fences to get out."

Reyes said that she didn't run at first because the gunshots sounded like fireworks. "It started going for five minutes, maybe three. It was like the movies — everyone was crying, people were screaming," she said.

Gilroy Garlic festival volunteers embrace at a reunification centre in a parking lot at Gavilan College. (Josie Lepe/Associated Press)

Todd Jones, a sound engineer, told the newspaper that he was at the front of the festival's Vineyard stage when he heard what sounded like a firework. "But then it started to increase, more rapidly, which sounded more like gunfire, and at that point people realized what was happening," Jones said.

Natalie Martinez, a Gilroy resident, told the Mercury News that she had gone to get food and separated from her two daughters. "I ran to find the girls and we basically ran into each other. I thought, We're open prey. It was awful," she said.

Video first posted on social media sites at about 5:30 p.m. local time showed people running for safety at the festival.

Gilroy is dubbed the 'Garlic Capital of the World,' and the annual garlic festival is a three-day celebration featuring food, cooking competitions and music that attracts more than 100,000 people. Sunday was the final day of this year's event. (Noah Berger/Associated Press)

Agents from the federal Bureau of Alcohol, Tobacco, Firearms and Explosives responded to the scene of the shooting.

The Gilroy Police Department on its Twitter account issued a statement saying: "The hearts of Gilroy PD and entire community go out to the victims of today's shooting at the Garlic Festival."

U.S. President Donald Trump tweeted about the shooting Sunday night, asking people to "be careful and safe!"