In this photo provided by the Lopez family is a picture of Andy Lopez, who was killed by sheriff's deputies in Santa Rosa, Calif., Tuesday. (AP Photo/Courtesy of Lopez family via The Press Democrat)

SANTA ROSA, Calif. — A Northern California community is anguished over the fatal police shooting of a popular, 13-year-old boy who had been carrying a pellet gun that looked like an assault rifle.

Sonoma County sheriff's deputies had repeatedly asked the boy, Andy Lopez, to drop the weapon, but instead he raised it in their direction, police said at a news conference Wednesday.

Only after the shooting did deputies realize the gun was a replica that looked strikingly similar to a real AK-47 assault rifle.

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. Many expressed their grief by leaving candles, teddy bears and flowers at the edge of the field where the teen was shot Tuesday afternoon.

Some community members wondered whether the deputies acted appropriately when they decided to fire on such a young person.

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."

Even members of law enforcement expressed sympathy.

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.

After the deputies spotted the boy Tuesday, they called for backup and repeatedly ordered him to drop the gun, sheriff's Lt. Dennis O'Leary said in a news release. His back was turned toward the deputies, and they did not realize at the time that he was a boy.

According to the Santa Rosa police, the boy was about 20 to 30 feet from them when he turned toward the deputies with the gun and they opened fire.

"First, I heard a single siren and within seconds I heard seven shots go off, sounded like a nail gun, is what I thought it was," he said.

The boy was pronounced dead at the scene.

At Wednesday's news conference, Santa Rosa police displayed the pellet gun, which resembled an AK-47 with a black magazine and brown butt.

Deputies also found a plastic handgun in the boy's waistband, O'Leary said. The deputies, who have not been identified, have been placed on administrative leave, which is standard after a shooting, he 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 also 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."