A Sonoma County sheriff's deputy twice asked the boy, Andy Lopez, to drop the weapon, but instead he raised it in their direction, police said at a news conference Wednesday.
"The deputy's mindset was that he was fearful that he was going to be shot," said Santa Rosa Police Lt. Paul Henry, whose agency is investigating the Tuesday afternoon shooting in Santa Rosa.
Only after the shooting did deputies realize the gun was a plastic replica that looked strikingly similar to a real AK-47 assault rifle, authorities said.
Residents of Santa Rosa, a suburban town of roughly 170,000 people about 50 miles northwest of San Francisco in California's wine country, were shaken by the boy's death.
Hundreds marched on Wednesday night to remember the teen and protest the shooting, chanting "We need justice," as they questioned how the deputy mistook a pellet gun for an assault rifle.
"We don't know the reason why they killed him," Katia Ontiveros, 18, told the Press Democrat of Santa Rosa. She said her brother was Andy's friend. "They should know if a gun is real."
The marchers went to the site at the edge of a field where the boy was shot. Community members had left candles, teddy bears and flowers there.
Andy, an eighth-grade student who played trumpet in his school band, was described as a bright and popular student, liked by many in his community, including Lawrence Cook Middle School assistant principal Linsey Gannon.
"Andy was a very loved student, a very popular, very handsome young man, very smart and capable," Gannon said Wednesday. "Our community has been rocked by his loss."
In a statement, Sheriff Steve Freitas said the shooting was a "tragedy" and that he would do everything he could to ensure the investigation was thorough and transparent.
"As a father of two boys about this age, I can't begin to imagine the grief this family is going through," he said.
Two deputies were riding in a marked patrol vehicle and were in their patrol uniforms when they spotted the teen in a hooded sweatshirt and shorts around 3:15 p.m. Tuesday, police said. His back was turned toward the deputies, and they did not realize he was a boy.
One of the deputies saw what appeared to be an assault-style rifle similar to an AK-47 in his left hand. The deputies pulled over and took cover behind an open passenger door, according to police.
A witness reported seeing their lights go off and hearing the chirp of a siren, police said.
One of the deputies ordered Andy to drop the weapon twice, according to a witness, police said. There was no language barrier that would have prevented the boy from understanding the deputy, according to police.
Andy was about 20 or 30 feet away from the deputies with his back toward them when he began turning around with what one deputy described as the barrel of the assault rifle rising up and turning in his direction, police said.
The deputy then fired several rounds, striking the boy at least once, Henry said. He was pronounced dead at the scene.
At Wednesday's news conference, Santa Rosa police displayed the pellet gun.
Deputies also found a plastic handgun in the boy's waistband, police said.
The pellet gun did not have an orange tip like other replica firearms, including the plastic handgun found in the boy's waistband, police said.
The deputies, who have not been identified, have been placed on administrative leave, which is standard after a shooting, sheriff's officials said.
The boy's family was back at their mobile home Tuesday night after identifying the teen's body, the Press Democrat reported.
Andy's father, Rodrigo Lopez, told the newspaper that he last saw his son Tuesday morning. He said the gun was a toy that belonged to a friend of his son's.
"I told him what I tell him every day," he said in Spanish. "Behave yourself."