GILROY, Calif. — Leaders and residents of Gilroy vowed at a community vigil Monday night not to let a gunman and his deadly attack on a garlic festival define their city and its distinctive annual celebration.

“We cannot let the bastard who did this tear us down,” Gilroy Mayor Roland Velasco told hundreds of people who had gathered to mourn the three killed in Sunday’s rampage.

The crowd, many with people wearing newly printed #gilroystrong T-shirts, loudly cheered the call for resilience and defiance in the shadow of the city's library.

“The person who did this took something from us,” Velasco said. “They took a small-town festival that has generated millions of dollars over 41 years, and took that from us.”

The city wouldn't let its unity be taken away, he said.

Three people, including two children, died and a dozen more were wounded Sunday at the Gilroy Garlic Festival. Stephen Romero, 6, Keyla Salazar, 13, and Trevor Irby, who officials said was in his 20s, died, and five of the 12 people wounded remained hospitalized Monday, medical officials said.

From left, Trevor Irby, Keyla Salazar, 13, and Stephen Romero, 6, were killed in the shootings at the Gilroy Garlic Festival.

Police officers shot and killed the gunman, a Gilroy resident. Authorities and witnesses said the suspect, identified Monday as Santino William Legan, 19, wore tactical gear and was armed with a military-style rifle.

He appeared to have cut through a fence that surrounded the festival, Gilroy police Chief Scot Smithee said.

Speakers at the vigil memorialized the victims and talked about their experiences during the attack. They prayed, denounced hatred, thanked police and emergency workers, addressed gun politics and read quotes from the pacifist leader Mohandas K. Gandhi, also known as Mahatma Gandhi, and the civil rights leader Martin Luther King Jr.

Residents lit hundreds of candles and chanted “Gilroy strong!” as the sun set on the Northern California city, about 30 miles southeast of San Jose.

“When the world looks at Gilroy, California, the garlic capital of the world, what are they going to say? Yes, Gilroy strong, but they're also going to say that we're a beacon of hope,” Richard Ruiz, a Gilroy native who addressed the crowd, said.

“We're like the Statue of Liberty, but instead of holding a flame, we're probably holding a head of garlic,” he said.

A woman leaves mementos at a makeshift memorial outside the site of the Gilroy Garlic Festival. Mario Tama / Getty Images

The garlic festival, which raises money for local charities, draws as many as 100,000 people and boosts local garlic growers. It is “the best of Gilroy,” City Council member Peter Leroe-Munoz said.

“The garlic festival is our annual showcase to the world — and to ourselves about the best we can be,” he said.

Kelly Ramirez, a resident who was at the festival during the shooting, said that because of the scale of the episode, everyone in the city now counts as a survivor of gun violence.

“I recall the people I was sheltering with in our tent — the painful faces of mothers whose children were somewhere in the park, but not with them,” Ramirez said.

“I don't believe this tragedy will define us, but I hope it will be a defining moment,” she said.

Residents of nearby Morgan Hill, where a gunman killed two people last month, counseled people in Gilroy to support one another.

“You, you and you — you all need to give hope to people around you,” said Rene Spring, Morgan Hill’s mayor pro tem.

Several at the vigil expressed frustration with politicians and the government’s inability to stop mass shootings.

State Sen. Bill Monning, a Democrat whose district includes Gilroy, said lawmakers ought to do something in response, though he provided no details Monday night.

“This is not normal, and our representatives have to make sure this never happens again,” Monning said.

Smithee, the police chief, said the gunman appeared to have opened fire “somewhat randomly,” though investigators hadn’t yet determined a motive. Police believe a second person may have been involved, Smithee said Monday, though it was unclear in what way.

A post published Sunday before the shooting on an Instagram account connected to the gunman referred to a proto-fascist white supremacist manifesto.

The manifesto, which is filled with anti-Semitic rhetoric and advocates racialized violence, has been used for years as a recruitment tool by white nationalists.

An FBI agent speaking to reporters Monday declined to discuss the Instagram account, saying he could only confirm that the gunman had recently opened a Facebook page.