ST. PAUL, Minn. (Reuters) - A Minnesota police officer on trial for the fatal shooting of a black motorist during a traffic stop last year, the aftermath of which was streamed on social media by the driver’s girlfriend, said on Friday he feared for his life.

FILE PHOTO: Minnesota police officer Jeronimo Yanez, charged in connection with the shooting death of a black motorist Philando Castile last July, is shown in this booking photo taken November 18, 2016 in St. Paul, Minnesota, U.S. Courtesy of Ramsey County Sheriff's Office/Handout via REUTERS

St. Anthony Police Department officer Jeronimo Yanez, who was charged with second-degree manslaughter, sparked national outrage and triggered weeks of protests in St. Paul and Minneapolis after he fatally shot Philando Castile, 32, last July.

On Friday, Yanez, who has pleaded not guilty, said at the Ramsey County District Court in St. Paul in sometimes emotional testimony that Castile disregarded the officer’s commands and began reaching for a firearm he had disclosed he had in his possession. Closing arguments in the trial are scheduled for Monday.

“I did not want to shoot Mr. Castile at all,” Yanez said as he took off his glasses and wiped away tears with a tissue. “That was not my intention.

“I was scared to death. I thought I was going to die,” he said in response to questions from his attorney. “I had no other choice.”

While holding a replica of Castile’s 9mm handgun, Yanez told the jury he saw part of the gun’s handle before opening fire.

The police dashboard camera video showed Castile ignored two commands to avoid reaching for or pulling out his gun, Yanez’s attorney, Paul Engh, said Monday.

The shooting in the St. Paul suburb of Falcon Heights, like similar incidents across the United States, fueled public debate about appropriate use of force by law enforcement against minorities.

The police video of the traffic stop and the Facebook Live post by Castile’s girlfriend Diamond Reynolds, who was in the passenger seat next to him, were played in court Monday. Yanez fired seven shots, hitting Castile five times, including twice in the heart, prosecutors said.

Reynolds said Tuesday she showed the video because she did not trust police. She testified she was afraid for her 4-year-old daughter, who was in the vehicle’s back seat.

Yanez has said he was justified in stopping Castile’s car because he resembled a suspect in a convenience store robbery, court documents said. Castile’s vehicle also had a broken brake light.

After Castile was stopped, Yanez asked him to present his driver’s license and insurance card. Castile disclosed he was carrying a licensed handgun. The exchange took just over a minute. Castile’s gun permit was later found in his wallet.