GILROY, Calif. — The gunman who killed three people and wounded a dozen more at the Gilroy Garlic Festival in Northern California was an angry 19-year-old who had recently waded into the world of white supremacy.

Santino William Legan, who was shot dead by police Sunday before he could do more damage, posted online about an 1890 racist manifesto, “Might is Right or The Survival of the Fittest,” NBC News confirmed.

“Read Might is Right by Ragnar Redbeard,” Legan posted on his Instagram page. He then used a slurs against mixed-race people and misogynistic descriptions of white Silicon Valley workers, complaining about "hordes" of them "overcrowding" towns.

Redbeard, which was a pseudonym, argued that only strength and violence determined what is morally right. The work, which is filled with misogynistic and anti-Semitic rhetoric, is a staple among neo-Nazis and white supremacists on extremist sites.

And the phrase “might is right” is often posted as a sort of motto or catchphrase indicating white supremacy on neo-Nazi extremist forums.

Legan was also apparently no fan of the festival, a three-day food fair that began in 1979 to celebrate the local garlic industry — and which was in walking distance from his home on a tree-lined street in Gilroy.

“Ayyy garlic festival time,” his post read. “Come get wasted on overpriced s---.”

Below that was a post from someone named futboieden, which read “when you get too wasted and accidentally shoot up the festival.”

Just who futboieden was remained unclear a day after the nation was left grappling with yet another mass shooting. This one claimed the lives of 6-year-old Stephen Romero, a 13-year-old girl, and a man in his 20s. The names of the other two victims were not released.

Investigators also said they were looking into reports that Legan might have had an accomplice but said that had not been confirmed. They said the AK-47-style assault rifle Legan used in the shooting was purchased July 9 in Nevada.

"We don't have a motive for the shooting as yet," Gilroy Police Chief Scot Smithee said during a press conference.

Legan was from a family of boxers. He was coached, along with his brothers, by their father, Tom.

Neighbors said the family converted its garage into a boxing gym and the boys were often seen sparring with each other.

Santino Legan in a high school yearbook photo.

“I’m so confused and hurt for the parents to go through this,” said Elia Scettrini, 65, who lives two doors away and teaches Spanish at Gilroy High School.

Scettrini said Legan just graduated from high school and described the family as friendly and polite.

Police on Monday could be seen carrying several bags of evidence out of the family home and searching a car parked outside.

This was not the first time the Legan family has found itself in the crosshairs of a police investigation.

Legan’s grandfather Thomas Legan was a Santa Clara County supervisor running for re-election in 1988 when he was accused of molesting one of his daughters six years earlier.

Thomas Legan, who died last year, insisted he was innocent and maintained his ex-wife had manipulated the girl into making a false accusation. A jury agreed and found him not guilty after six days of deliberations.

Rep. Dan Lipinski, D-Ill., said he and his wife, Judy, were in the crowd Sunday when the shots rang out.

"The shooter was not far from us as we heard the loud 'pops,' which seemed to get closer as we ran," the congressman said in a statement.

The Gilroy Garlic Festival is one of the county’s best-known food festivals and has been held for 41 years. It draws hundreds of thousands of paying visitors every year.

The focus of the festival is garlic-flavored food, from garlic bread and calamari to ice cream and frog legs, and some people even show their fondness for the plant by wearing garlic-shaped hats.

The festival made several changes this year to try to reverse a recent 20 percent decline in attendance, Gilroy Life, a local lifestyle publication, reported last week. The changes included adding a concert by singer-songwriter Colbie Caillat and an appearance by celebrity chef Tom Colicchio.

The festival is run primarily by volunteers and much of the money goes to local charities.

“It’s been able to supply money for all groups, whether it’s the little kids’ swimming team or the high school football teams,” said Alex Larson, 57, who owns the Garlic Shoppe in Gilroy with his brother.

Larson said the festival is so central to the community that people will rally behind it, rather than letting the shooting mar its reputation.

“If it were a festival that someone was profiting from, it would be completely different, but this is a festival that everyone profits from,” he said. Next year, he said, “People are going to show up, and it’s going to be better.”

People in Gilroy were using the hashtag #gilroystrong on social media on Monday, echoing a saying that became popular in Boston after the marathon bombing there in 2013.

David Ingram reported from Gilroy, and Brandy Zadrozny and Corky Siemaszko from New York.