ST. PAUL, Minn. — When Philando Castile was pulled over in July, he calmly told the officer he had a gun and was licensed to carry it, according to prosecutors. Moments later, the officer fired on the motorist, and a bleeding Castile uttered his last words: “I wasn’t reaching for it.”

On Wednesday, that officer was charged with second-degree manslaughter following an investigation by prosecutors, who concluded that Jeronimo Yanez was wrong to use his weapon in the traffic stop, which was seen by millions after Castile’s girlfriend streamed his final gruesome moments live on Facebook.

“No reasonable officer, knowing, seeing and hearing what officer Yanez did at the time, would’ve used deadly force under these circumstances,” Ramsey County Attorney John Choi said.

Prosecutors believe Castile never tried to pull his handgun from his pocket, and Yanez’s unreasonable fear did not justify the shooting, Choi said.

If convicted, the officer could face up to 10 years in prison.

Diamond Reynolds was sitting next to her boyfriend in the car. She said he was shot repeatedly as he reached for his ID after telling Yanez about the weapon and the gun permit.

The fatal shootings of black men and boys by police officers have come under heightened scrutiny since the 2014 death of Michael Brown in Ferguson, Missouri.

No charges were filed against the officer in that case, but Brown’s death led to calls nationwide for officers to be held criminally responsible.

Yanez, who worked in the Minneapolis suburb of St. Anthony, was scheduled to make his first court appearance Friday.

His attorney, Tom Kelly, has said Yanez, who is Latino, was reacting to the presence of a gun. Kelly also said one reason Yanez made the stop was because he thought Castile looked like a possible match for an armed robbery suspect.

Choi said Wednesday Castile was not a suspect in that robbery. Castile’s relatives have said they believe the 32-year-old elementary school cafeteria worker was racially profiled.

Castile’s mother, Valerie Castile, said her family was pleased with the charge.

“It is necessary for everyone to understand that we want peace,” she said. “We don’t want any protests to get outrageous.”

Castile’s shooting prompted numerous protests, including a demonstration outside the governor’s mansion that went on for weeks and one protest that shut down Interstate 94 in St. Paul for hours.