Legan had posted online about an 1890 racist manifesto, “Might is Right or The Survival of the Fittest.”
“Read Might is Right by Ragnar Redbeard,” Legan posted on his Instagram page. He then used a slur against mixed-race people and complained about "hordes" of them "overcrowding" towns.
Police said the 19-year-old gunman on Sunday cut through a fence to avoid security and opened fire at the annual festival in Gilroy, California. Three people were killed: 6-year-old Stephen Romero, 13-year-old Keyla Salazar of San Jose, and 25-year-old Trevor Irby, a 2017 graduate of Keuka College in New York. Twelve others were also hurt in the shooting.
Responding officers quickly made contact with the gunman, who police said was shot and killed.
Legan's since-deleted Instagram account says he is Italian and Iranian. It also shows a photo he posted earlier depicting Smokey the Bear in front of a "fire danger" sign.
Law enforcement, including ATF, early Monday searched Legan's family's home in Gilroy. Police and ATF agents were seen leaving the home with evidence bags.
Police on Monday said the gunman used an AK-47 type assault rifle purchased legally in Nevada on July 9.
A motive for the shooting remains unknown.
"This is a tragic incident for our community," Gilroy Mayor Roland Velasco said. "On behalf of the city and the Gilroy City Council our thoughts and prayers go out the victims and families."
There were reports that a second suspect may have been involved in the shooting. Police are still trying to determine if that is the case.
"We don't have any confirmation that any second suspect did any shooting, but we certainly are investigating all leads to try to determine who that potential second suspect is and what exactly that person's role was," Gilroy Police Chief Scot Smithee said Monday.
The festival, now in its 41st year, is a local tradition that attracts thousands annually. It was wrapping up its third and final day when reports of the shooting came in.
"We are heartbroken that senseless violence brought this year's festival to such a terrible and tragic end," Shawn Keck, president of the 2019 Gilroy Garlic Festival, said in a statement. "We are truly grateful to the Gilroy Police Department, who responded immediately to prevent further loss of life, and to the hundreds of other first responders from regional and federal agencies who have provided additional support. We are also thankful for the thoughts and prayers and outpouring of support from people all over the world."