Photo: Carlos Avila Gonzalez / The Chronicle Photo: Screenshot

A 19-year-old man who went on a shooting rampage at the Gilroy Garlic Festival legally bought his rifle in Nevada, but broke the law by bringing the gun into California, where it would fall under the state’s assault weapons ban, a federal law enforcement official told The Chronicle Monday.

Santino William Legan, a Bay Area native who lived in Walker Lake, Nev., legally bought the WASR-10 semiautomatic rifle with a detachable magazine at Big Mikes Gun and Ammo in Fallon (Churchill County) on July 9, less than three weeks before Sunday’s shooting, the official said.

Nevada does not prohibit such rifles from being bought and sold, and the owner of Big Mikes said there were no red flags during the sale, which began as an online order.

“It’s absolutely illegal to bring into California,” said the source, who asked for anonymity because the person was not authorized to speak to the media.

The official said that, in theory, modifications could be made to such a rifle to make it legal in California, such as welding a magazine into place, but added that no such changes were made to the gun used at the festival.

Gilroy police said Legan cut through a perimeter fence at the event and fired the AK-47-type assault rifle in what appeared to be a random manner, killing a 6-year-old boy, a 13-year-old girl and a man in his 20s, while injuring 12 other people, before police shot and killed him. The motive is unknown.

Legan lived about 60 miles south of Fallon. He grew up in Gilroy, where much of his family still resides, but has a brother in Reno.

In addition to the rifle, Legan legally purchased a Remington 870 shotgun on July 1 at a gun shop in Reno, the federal official said. Such guns are permitted in California. Neither of the gun stores said to have sold to Legan could be reached for comment.

On Monday morning, though, the Fallon gun store posted condolences on its Facebook page to the victims, while questioning the federal minimum age of 18 to purchase a firearm: “We feel so sorry for the Families of the CA shooting. May the POS rest in Hell. Maybe people need to be 21 to buy?”

Photo: Ashinn11, Wikimedia Commons

The owner later edited that post to include a longer message, saying he was “heartbroken” and recalling his interaction with the teenager.

“I did not know this individual. He ordered the rifle off my internet page. When I did see him, he was acting happy and showed no reasons for concern,” the owner wrote. “I would never ever sell any firearm to anyone who acted wrong or looks associated with any bad group like white power. Everyone is my brother and sister and I am (mourning) for the families.”

The owner said he owns a small home business and tries to sell to people “who we think are upstanding citizens to promote safe sport shooting. I pray to God for all the families.”

A frustrated California Attorney General Xavier Becerra noted Monday that Legan had only recently bought the gun.

“The reach of the California law ends at our border,” he said, “and so we cannot control what other states do, and that’s what makes it so tough. We may have progressive gun laws, but if other states don’t match us, we have to rely on the ability to catch” the person.

The state assault weapons ban, the Roberti-Roos Assault Weapons Control Act of 1989, is the oldest of its kind in the country. It passed after a man sprayed a Stockton schoolyard with dozens of rounds from a semiautomatic rifle in January 1989, killing five children and wounding 29 others and a teacher before killing himself.

The ban inspired similar prohibitions in other states as well as a 10-year federal assault weapons ban that expired in 2004.

The California law initially banned the sale of more than 50 models of semiautomatic rifles and pistols. A semiautomatic gun is one that, when fired, loads the next round of ammunition automatically, but requires a squeeze of the trigger for each shot.

A provision in the legislation allowed the state to add models to the banned list as they came to the attention of the attorney general. And in a later bid to stop gun makers from circumventing the law, legislators prohibited certain characteristics of weapons.

Guns with fixed magazines can’t hold more than 10 rounds. Those with detachable magazines, which enable swift reloading, can’t have any of a number of features that give them added functions or make them easier to handle, such as forward grips, folding stocks, flash suppressors and shrouds to protect a shooter from burns.

The ban has survived court challenges, but gun makers have found ways around it, selling firearms similar to banned ones. And guns purchased before the ban were protected by a grandfather clause.

The type of gun recovered in Gilroy has been used in other mass shootings. On Dec. 5, 2007, Robert Hawkins killed eight people and wounded five others before shooting himself at the Westroads Mall in Omaha, Neb. He used a WASR-10 assault rifle with two 30-round magazines taped together. He was also 19.

Last October, as part of the trial of Mexican drug lord Joaquin “El Chapo” Guzman, the Bureau of Alcohol, Tobacco, Firearms and Explosives put out a memo on some of the weapons seized in the case. They described how WASR-10s are manufactured in Romania and imported into the United States, where the single-stack magazine is modified to replicate the same features as a non-importable, assault-rifle version. The new version, the ATF wrote, would accept a 30-round magazine.

The report noted that such semiautomatic firearms are “readily convertible to fire automatically” with a hand drill and $16 worth of unregulated parts. The ATF said the drilling would take less than 60 seconds, plus another five to 10 minutes to install the parts.

Matthias Gafni is a San Francisco Chronicle staff writer. Email: matthias.gafni@sfchronicle.com Twitter: @mgafni