GILROY, Calif. -- The 19-year-old gunman who opened fire at a Northern California food festival was "kind of a loner" and much of his life was shrouded in mystery, the FBI said Tuesday as investigators searched for a motive.

Police believe Santino William Legan fired randomly Sunday, killing three people, after cutting through a fence to get into the Gilroy Garlic Festival. Officers patrolling the popular event responded within a minute and killed him.

Legan attended high school in Gilroy in his senior year and was recently living in Nevada, where he purchased two guns -- the AK-47-style semi-automatic rifle he used in the attack and a shotgun that was found in his car near the festival, authorities said.

A bag of ammunition was found in a creek near the fence, police said.

"We understand him to be kind of a loner," said Craig Fair, deputy special agent in charge of the FBI's San Francisco Division. "People who act alone are exceptionally dangerous because they ... may not communicate their plans, intentions, mindset -- they may not impart that on other people."

Legan was living in an apartment in Walker Lake, a remote northern Nevada community, and had not had any run-ins with the law, officials said.

"He appears to have moved into Mineral County this spring and maintained a low profile," Sheriff Randy Adams said in a statement.

Officials searched the apartment, seizing empty shotgun and rifle boxes, a gas mask, empty ammunition boxes, electronic devices, pamphlets on guns and a sack full of ammunition casings, prosecutors said.

The FBI said they were looking through Legan's social media, emails and phone to find out who he was talking to and what he was expressing and thinking. Authorities don't believe he was targeting anyone based on any specific characteristics like race, but they're still trying to determine his ideology, Fair said.

On the day of the attack, Legan urged his Instagram followers to read a 19th century book popular with white supremacists on extremist websites. He also complained about overcrowding towns and paving open space to make room for "hordes" of Latinos and Silicon Valley whites.

Legan posted a photo from the festival minutes before opening fire, saying, "Come get wasted on overpriced" items. His since-deleted Instagram account says he is Italian and Iranian.

While some killers in recent mass shootings have taken to posting writing or even broadcasting their attacks, there are cases where shooters leave very little public footprint and no motive is uncovered.

That includes the gunman who carried out the deadliest mass shooting in modern U.S. history. No clear motive was found for why Stephen Paddock killed 58 people at an outdoor music festival in Las Vegas in 2017, though the FBI said he sought notoriety.

Gilroy Police Chief Scot Smithee told reporters that authorities believe Legan acted alone but are still investigating. Investigators tracked Legan's movements around town before the shooting, and video shows him visiting stores alone, Smithee said.

People had to pass through metal detectors and have their bags searched at the long-running festival that draws more than 100,000 people with music, food booths and cooking classes to the city roughly 80 miles (176 kilometres) southeast of San Francisco.

Police, paramedics and firefighters were stationed throughout the event, along with FBI agents who, in a common practice, had been asked to keep an eye on the event, authorities said.

Legan bypassed those security measures by cutting through the fence.

He killed 6-year-old Stephen Romero and 13-year-old Keyla Salazar of San Jose, along with Trevor Irby, 25, of Romulus, New York, who was at the event with his girlfriend. She wasn't hurt.

A dozen other people were injured. At least seven victims remained hospitalized Tuesday, the San Francisco Chronicle reported.

------

Associated Press reporter Stefanie Dazio in Los Angeles contributed to this report.