Editors note: In a story Aug. 1 about the murder trial of former St. Louis police officer Jason Stockley, The Associated Press reported erroneously that another officer recovered the gun found in Anthony Lamar Smith's car. It was Stockley who recovered the gun.

A corrected version of the story is below:

A white former St. Louis police officer charged with killing a black man "executed" him after a car chase, then planted a gun in the slain drug suspect's vehicle as an excuse for opening fire, a prosecutor told a court Tuesday.

But an attorney for the officer denied the prosecutor's allegations during opening statements in the first-degree murder trial for Jason Stockley, saying the officer was protecting himself against an armed and dangerous felon.

It was the first time that prosecutors have revealed publicly that they believe that Stockley, 36, planted a gun on 24-year-old Anthony Lamar Smith after Smith was shot in December 2011. Stockley, who resigned from the department in 2013 and now lives in Houston, wasn't charged until last year, after then-Circuit Attorney Jennifer Joyce cited unspecified new evidence. The first-degree murder trial will be decided by a judge rather than a jury despite objections from prosecutors.

It's unusual for officers to be charged with killing suspects while on duty, and few officers are convicted in such deaths.

A key issue in the trial is the unloaded .38-caliber revolver that Stockley said he found inside Smith's rented Buick. Stockley has said he unloaded the weapon as a safety precaution after shooting Smith.

Assistant Circuit Attorney Aaron Levinson said Stockley shot Smith five times, including once while standing 6 inches from him, which Levinson called the "kill shot." He said Stockley then returned to the Buick multiple times.

Stockley's DNA — but not Smith's — was found on the gun, though Smith's DNA was found on a bag of heroin inside the car, the prosecutor said.

"Anthony Smith did not deserve to die," Levinson said. "He may have fled from police, but he did not deserve to be executed."

But Stockley's attorney, Neil Bruntrager, said both officers saw the gun inside the car before the chase started. Stockley opened fire only after Smith refused commands to put up his hands and reached along the seat "in the area where the gun was," Bruntrager said, describing Smith as a parole violator "who decided to do whatever was necessary to avoid arrest because he was going to jail." Smith had previous convictions for gun and drug crimes.

A longtime friend of Smith's, Kirkwin Taylor, testified that he rode in the car with Smith to the restaurant that morning and did not see a gun in the vehicle.

Video from a police dashboard camera and witnesses, along with DNA evidence, are expected to play a big role in the trial of Stockley, described by Bruntrager as a West Point graduate who served in Iraq and graduated first in his police academy class.

The shooting happened after Stockley and his partner spotted Smith in a suspected drug transaction in the parking lot of a fast-food restaurant.

Police dashboard recordings and two videos show the officers pulled behind Smith's car. As they got out, Smith backed into the police SUV and sped past Stockley, who was carrying his personal AK-47 rifle that was nearly knocked from his hands. Police have said Stockley was not authorized to carry that weapon on duty.

Stockley fired several shots from his department-issued pistol, breaking the rear window of the Buick, and the chase ensued, with speeds reaching 87 mph (140 kph). Stockley reported shots being fired. According to court records, he then said, "Going to kill this (expletive), don't you know it," — something Bruntrager denied.

The officers eventually rammed their SUV into the back of Smith's car, causing its air bags to deploy. The officers got out, leading to the fatal encounter.

The courtroom was filled with onlookers, including many people active in protests in nearby Ferguson, Missouri, following the fatal police shooting of Michael Brown in 2014. Supporters of Stockley were also present. Circuit Judge Timothy Wilson opened the hearing with a warning that any outbursts would not be tolerated.

"Earlier this year, Ringling Brothers Circus died," the judge said. "It will not be resurrected here."